Method for encoding/decoding image signal, and device therefor

ABSTRACT

A method for decoding an image according to the present invention may comprise the steps of: deriving a residual coefficient of a current block; dequantizing the residual coefficient; deriving a common residual signal by performing inverse transform of the dequantized residual coefficient; and deriving a first residual signal of a first chroma component and a second residual signal of a second chroma component on the basis of the common residual signal.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application claims the benefit under 35 U.S.C. section 371, of PCTInternational Application No.: PCT/KR2020/003482, filed on Mar. 12,2020, which claims foreign priority to Korean Patent Application No.:10-2019-0027938, filed on Mar. 12, 2019 and Korean Patent ApplicationNo.: 10-2019-0056770, filed on May 15, 2019, in the Korean IntellectualProperty Office, the disclosures of which are hereby incorporated byreference in their entireties.

FIELD OF THE DISCLOSURE

The present disclosure relates to a video signal encoding/decodingmethod and a device therefor.

DESCRIPTION OF THE RELATED ART

As display panels become larger, video service of higher quality isrequired. The biggest problem with high-definition video service is thatan amount of data is greatly increased. In order to solve the aboveproblem, research for improving the video compression rate is beingactively conducted. As a representative example, the Joint CollaborativeTeam on Video Coding (JCT-VC) was formed in 2009 by the Motion PictureExperts Group (MPEG) and the Video Coding Experts Group (VCEG) under theInternational Telecommunication Union-Telecommunication (ITU-T). TheJCT-VC proposed High Efficiency Video Coding (HEVC), a video compressionstandard that has about twice compression performance of H.264/AVC, andthat was approved as standard on Jan. 25, 2013. However, with rapiddevelopment of high-definition video services, the performance of HEVCis gradually showing its limitations.

DISCLOSURE Technical Purpose

A purpose of the present disclosure is to provide a device forperforming a method of jointly encoding a residual component of chromacomponents in encoding/decoding a video signal, and a device forperforming the method.

A purpose of the present disclosure is to provide a device forperforming a method of selectively using various methods generating ajoint chroma signal for chroma components in encoding/decoding a videosignal, and a device for performing the method.

A purpose of the present disclosure is to provide a device forperforming a method of performing the second transform inencoding/decoding a video signal, and a device for performing themethod.

Technical purposes obtainable from the present disclosure arenon-limited to the above-mentioned technical purposes, and otherunmentioned technical purposes may be clearly understood from thefollowing description by those having ordinary skill in the technicalfield to which the present disclosure pertains.

Technical Solution

A video signal decoding method according to the present disclosure mayinclude deriving a residual coefficient of a current block, dequantizingthe residual coefficient, deriving a joint residual signal by performinginverse transform for the dequantized residual coefficient and derivingthe first residual signal for the first chroma component and the secondresidual signal for the second chroma component based on the jointresidual signal.

A video signal encoding method according to the present disclosure mayinclude generating a joint residual signal based on the first residualsignal for the first chroma component and the second residual signal forthe second chroma component, transforming the joint residual signal,deriving a residual coefficient by quantizing the transformed jointresidual signal and encoding the residual coefficient.

A video signal decoding method according to the present disclosure mayfurther include determining one of a plurality of residual signalreconstruction mode candidates as a residual signal reconstruction modefor the current block.

In a video signal decoding method according to the present disclosure, amethod of deriving the first residual signal may be different betweenwhen the first residual signal reconstruction mode is selected among theplurality of residual signal reconstruction mode candidates and when thesecond residual signal reconstruction mode is selected among theplurality of residual signal reconstruction mode candidates.

In a video signal decoding method according to the present disclosure,when the first residual signal reconstruction mode is selected, thefirst residual signal may be derived to be the same as the jointresidual signal and when the second residual signal reconstruction modeis selected, the first residual signal may be derived to have a signopposite to the joint residual signal or by scaling the joint residualsignal.

In a video signal decoding method according to the present disclosure,parsing information for specifying the residual signal reconstructionmode may be further included.

In a video signal decoding method according to the present disclosure,the information may include the first flag representing whether there isa non-zero transform coefficient of the first chroma component in thecurrent block and the second flag representing whether there is anon-zero transform coefficient of the second chroma component in thecurrent block.

In a video signal decoding method according to the present disclosure,the first residual signal may have the same sign as the joint residualsignal and the second residual signal may have a sign opposite to thejoint residual signal.

It is to be understood that the foregoing summarized features areexemplary aspects of the following detailed description of the presentdisclosure without limiting the scope of the present disclosure.

Technical Effect

According to the present disclosure, encoding/decoding efficiency of avideo signal may be improved by jointly encoding a residual component ofchroma components.

According to the present disclosure, encoding/decoding efficiency of avideo signal may be improved by selectively using a variety of methodswhich generate a joint chroma signal.

According to the present disclosure, encoding/decoding efficiency may beimproved by performing transform for a residual signal multiple times.

Effects obtainable from the present disclosure may be non-limited by theabove-mentioned effect, and other unmentioned effects may be clearlyunderstood from the following description by those having ordinary skillin the technical field to which the present disclosure pertains.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a view showing a block diagram of a video encoding device(encoder) according to an embodiment of the present disclosure;

FIG. 2 is a view showing a block diagram of a video decoding device(decoder) according to an embodiment of the present disclosure;

FIG. 3 is a view showing a basic coding tree unit according to anembodiment of the present disclosure;

FIG. 4 is a view showing various partitioning types of a coding block.

FIG. 5 is a view of an example showing an aspect of partitioning a CTU.

FIG. 6 is a flow diagram of an inter prediction method according to anembodiment of the present disclosure.

FIG. 7 is a flow diagram of a process deriving the current block motioninformation under a merge mode.

FIG. 8 is a diagram of illustrating candidate blocks used to derive amerge candidate.

FIG. 9 is a diagram illustrating candidate blocks used to derive a mergecandidate.

FIG. 10 is a diagram to explain the update aspect of a motioninformation table.

FIG. 11 is a diagram showing the update aspect of a motion informationtable.

FIG. 12 is a diagram showing an example in which the index of apre-saved motion information candidate is renewed.

FIG. 13 is a diagram showing the position of a representative sub-block.

FIG. 14 shows an example in which a motion information table isgenerated per inter-prediction mode.

FIG. 15 shows an example in which a motion information table isgenerated per motion vector resolution.

FIG. 16 shows an example in which the motion information of a block towhich a merge offset encoding method is applied is stored in a separatemotion information table.

FIG. 17 is a diagram showing an example in which a motion informationcandidate included in a long-term motion information table is added to amerge candidate list.

FIG. 18 is a diagram showing an example in which a redundancy check isperformed only for a part of merge candidates.

FIG. 19 is a diagram showing an example in which a redundancy check witha specific merge candidate is omitted.

FIG. 20 is a diagram showing an example in which a candidate blockincluded in the same merge processing region as a current block is setto be unavailable as a merge candidate.

FIG. 21 is a diagram showing an example deriving a merge candidate for acurrent block when a current block is included in a merge processingregion.

FIG. 22 is a diagram showing a temporary motion information table.

FIG. 23 is a diagram showing an example in which a motion informationtable and a temporary motion information table are unified.

FIG. 24 is a diagram showing an example in which a coding block ispartitioned into a plurality of prediction units by using a diagonalline.

FIG. 25 is a diagram showing an example in which a coding block ispartitioned into two prediction units.

FIG. 26 shows examples in which a coding block is partitioned into aplurality of different-sized prediction blocks.

FIG. 27 is a diagram showing neighboring blocks used to derive apartitioning mode merge candidate.

FIG. 28 is a diagram for explaining an example in which the availabilityof a neighboring block is determined per prediction unit.

FIGS. 29 and 30 are diagrams showing an example in which a predictionsample is derived based on a weighted sum operation of the firstprediction sample and the second prediction sample.

FIG. 31 is a flow diagram of an intra-prediction method according to theembodiment of the present disclosure.

FIG. 32 is a diagram showing intra-prediction modes.

FIGS. 33 and 34 are a diagram showing an example of a one-dimensionalarray which arranges reference samples in a line.

FIG. 35 is a diagram illustrating an angle formed by directionalintra-prediction modes with a straight line parallel to an x-axis.

FIG. 36 is a diagram showing an aspect in which a prediction sample isobtained when a current block has a non-square shape.

FIG. 37 is a diagram showing wide angle intra-prediction modes.

FIG. 39 is a diagram showing an example of vertical directionalpartitioning and horizontal directional partitioning.

FIG. 39 is a diagram showing an example in which a partitioning type ofa coding block is determined.

FIG. 40 is a diagram showing an example in which a partitioning type ofa coding block is determined.

FIG. 41 is a diagram showing an example in which a partitioning type ofa coding block is determined based on an intra-prediction mode of acoding block.

FIG. 42 is a diagram for describing a partitioning aspect of a codingblock.

FIG. 43 is a diagram showing an example in which whether transform skipis performed or not is determined per sub-block.

FIG. 44 is a diagram showing an example in which sub-blocks use the sametransform type.

FIGS. 45 and 46 are diagrams showing an application aspect of asub-transform block encoding method.

FIGS. 47 and 48 show a horizontal directional transform type and avertical directional transform type according to a position of asub-block which is a target of a transform.

FIG. 49 is a diagram showing an encoding aspect of a transformcoefficient when a reduce factor is 16.

FIGS. 50 and 51 are diagrams showing an example in which the secondtransform is performed for an available sub-block.

FIGS. 52 and 53 are diagrams showing a flow chart of a joint chrominanceresidual transformation method according to an embodiment of the presentdisclosure.

DETAILED DESCRIPTION OF THE DISCLOSURE

Hereinafter, embodiments of the present disclosure will be described indetail with reference to the accompanying drawings.

Image encoding and decoding is performed on a basis of a block. In anexample, for a coding block, a transform block, or a prediction block,encoding/decoding processes such as transform, quantization, prediction,in-loop filtering, reconstruction, etc. may be performed.

Hereinafter, an encoding/decoding target block is referred to as a“current block”. In an example, a current block may represent a codingblock, a transform block, or a prediction block according to a currentprocess of encoding/decoding.

In addition, the term “unit” used in the present specificationrepresents a basis unit for performing a specific encoding/decodingprocess, and a “block” may be understood to represent a sample arrayhaving a predetermined size. Unless otherwise stated, “block” and “unit”may be used interchangeably. In an example, in examples described later,a coding block and a coding unit may be understood to have the samemeaning as each other.

FIG. 1 is view showing a block diagram of an image encoding apparatus(encoder) according to an embodiment of the present disclosure.

Referring to FIG. 1, an image encoding apparatus 100 may include apicture partitioning unit 110, prediction units 120 and 125, a transformunit 130, a quantization unit 135, a rearrangement unit 160, an entropyencoding unit 165, a dequantization unit 140, an inverse-transform unit145, a filter unit 150, and a memory 155.

Components described in FIG. 1 are independently illustrated in order toshow different characteristic functions in an image encoding apparatus,and the figure does not mean that each component is constituted byseparated hardware or one software unit. That is, each component is justenumerated for convenience of explanation, at least two components ofrespective components may constitute one component or one component maybe partitioned into a plurality of components which may perform theirfunctions. Even an embodiment of integrating respective components andembodiment of dividing a component are also included in the scope of thepresent disclosure unless they are departing from the spirit of thepresent disclosure.

Further, some components are not requisite components that performessential functions of the present disclosure but are optionalcomponents for just improving performance. The present disclosure may beimplemented with the requisite component for implementing the spirit ofthe present disclosure other than the component used to just improve theperformance and a structure including only the requisite component otherthan the optional component used to just improve the performance is alsoincluded in the scope of the present disclosure.

The picture partitioning unit 110 may partition an input picture into atleast one processing unit. In this connection, the processing unit maybe a prediction unit (PU), a transform unit (TU), or a coding unit (CU).In the picture partitioning unit 110, a single picture may bepartitioned into combinations of a plurality of coding units, predictionunits, and transform units, and the picture may be encoded by selectinga combination of the coding units, the prediction units, and thetransform units according to a predetermined condition (for example,cost function).

For example, a single picture may be partitioned into a plurality ofcoding units. In order to partition a picture into coding units, arecursive tree structure such as a quad-tree structure may be used, anda coding unit that is originated from a root such as a single image orlargest coding unit may be partitioned into other coding units and mayhave child nodes as many as the partitioned coding units. A coding unitthat is no longer partitioned according to certain restrictions becomesa leaf node. Namely, when it is assumed that only square partitioning isavailable for a single coding unit, a single coding unit may bepartitioned into at most four other coding units.

Hereinafter, in the embodiment of the present disclosure, a coding unitmay be used as a unit for encoding or may be used as a unit fordecoding.

A prediction unit may be obtained by partitioning a single coding unitinto at least one square or rectangle having the same size, or a singlecoding unit may be partitioned into prediction units in such a mannerthat one prediction unit may be different from another prediction unitin a shape and/or size.

In generation of a prediction unit based on a coding block to whichintra-prediction is being performed, when the coding unit is not thesmallest coding unit, intra-prediction may be performed withoutperforming partitioning into a plurality of N×N prediction units.

The prediction units 120 and 125 may include an inter-prediction unit120 performing inter-prediction and an intra prediction unit 125performing intra-prediction. Whether to perform inter-prediction orintra-prediction on a prediction unit may be determined, and detailedinformation (for example, an intra-prediction mode, a motion vector, areference picture, etc.) according to each prediction method may bedetermined. In this connection, a processing unit on which prediction isperformed may differ with a processing unit for which a predictionmethod, and detail thereof are determined. For example, a predictionmethod, a prediction mode, etc. may be determined on the basis of aprediction unit, and prediction may be performed on the basis of atransform unit. A residual value (residual block) between the generatedprediction block and an original block may be input to the transformunit 130. In addition, prediction mode information used for prediction,motion vector information, etc. may be encoded using a residual value bythe entropy encoding unit 165 and may be transmitted to the decoder.When a specific encoding mode is used, an original block is encoded asit is and transmitted to a decoding unit without generating a predictionblock through the prediction unit 120 or 125.

The inter-prediction unit 120 may predict a prediction unit on the basisof information on at least one of a previous picture and a subsequentpicture of a current picture, or in some cases, may predict a predictionunit on the basis of information on some encoded regions in the currentpicture. The inter-prediction unit 120 may include a reference pictureinterpolation unit, a motion prediction unit, and a motion compensationunit.

The reference picture interpolation unit may receive reference pictureinformation from the memory 155, and generate pixel information of apixel at an integer or less from the reference picture. In case of aluma pixel, an 8-tap DCT-based interpolation filter having differentcoefficients may be used so as to generate pixel information on a pixelat an integer or less for a ¼ pixel unit. In case of a chroma signal, a4-tap DCT-based interpolation filter having different filtercoefficients may be used so as to generate pixel information on a pixelat an integer or less for a ⅛ pixel unit.

The motion prediction unit may perform motion prediction based on areference picture interpolated by the reference picture interpolationunit. As methods for calculating a motion vector, various methods, suchas a full search-based block matching algorithm (FBMA), a three stepsearch (TSS) algorithm, a new three-step search (NTS) algorithm, etc.may be used. A motion vector may have a motion vector value in a unit of½ or ¼ pixel on the basis of the interpolated pixel. The motionprediction unit may predict a current prediction unit by varying amotion prediction method. As motion prediction methods, various methods,such as a skip method, a merge method, an advanced motion vectorprediction (AMVP) method, an intra block copy method, etc. may be used.

The intra-prediction unit 125 may generate a prediction unit on thebasis of information on a reference pixel around a current block, whichis pixel information in a current picture. When a neighboring block of acurrent prediction unit is a block for which inter-prediction isperformed, and thus a reference pixel is a pixel for whichinter-prediction is performed, a reference pixel included in the blockfor which inter-prediction is performed may be replaced by informationon a reference pixel of a neighboring block for which intra-predictionis performed. In other words, when a reference pixel is unavailable, atleast one reference pixel of available reference pixels may be used inplace of unavailable reference pixel information.

A prediction mode in intra-prediction may include a directionalprediction mode using reference pixel information according to aprediction direction and a non-directional mode not using directionalinformation when performing prediction. A mode for predicting lumainformation may be different from a mode for predicting chromainformation. In order to predict the chroma information, information onan intra-prediction mode used for predicting the luma information orinformation on a predicted luma signal may be used.

In performing intra-prediction, when a prediction unit is identical in asize with a transform unit, intra-prediction may be performed on theprediction unit on the basis of pixels positioned at the left, thetop-left, and the top of the prediction unit. However, in performingintra-prediction, when a prediction unit is different in a size with atransform unit, intra-prediction may be performed by using a referencepixel based on the transform unit. In addition, intra-prediction usingN×N partitioning may be only used for the smallest coding unit.

In an intra-prediction method, a prediction block may be generated afterapplying an adaptive intra smoothing (AIS) filter to a reference pixelaccording to a prediction mode. A type of AIS filter applied to areference pixel may vary. In order to perform an intra-predictionmethod, an intra prediction mode for a current prediction unit may bepredicted from an intra-prediction mode of a prediction unit presentaround the current prediction unit. In predicting a prediction mode fora current prediction unit by using mode information predicted from aneighboring prediction unit, when an intra prediction mode for thecurrent prediction unit is identical to an intra prediction mode of theneighboring prediction unit, information indicating that the currentprediction unit and the neighboring prediction unit have the sameprediction mode may be transmitted by using predetermined flaginformation. When a prediction mode for the current prediction unit isdifferent from prediction modes of the neighboring prediction units,entropy encoding may be performed to encode information on a predictionmode for a current block.

In addition, a residual block may be generated which includesinformation on a residual value that is a difference value between aprediction unit for which prediction is performed on by the predictionunit 120 or 125, and an original block of the prediction unit. Thegenerated residual block may be input to the transform unit 130.

The transform unit 130 may perform transform on a residual block, whichincludes information on a residual value between an original block and aprediction unit generated by the prediction unit 120 or 125, by using atransform method such as discrete cosine transform (DCT) or discretesine transform (DST). In this connection, a DCT transform core includesat least one of DCT2 or DCT8 and a DST transform core includes DST7.Whether to apply DCT, or DST so as to perform transform on a residualblock may be determined on the basis of information on anintra-prediction mode of a prediction unit which is used to generate theresidual block. It is possible to skip a transform for a residual block.A flag indicating whether or not to skip a transform for a residualblock may be encoded. Transform skip may be allowed for a residual blockwhose a size is smaller than or equal to a threshold value, a residualblock of a luma component, or a residual block of a chroma componentunder 4:4:4 format.

The quantization unit 135 may perform quantization on values transformedinto a frequency domain by the transform unit 130. A quantizationcoefficient may vary according to a block or importance of an image.Values calculated in the quantization unit 135 may be provided to thedequantization unit 140 and the rearrangement unit 160.

The rearrangement unit 160 may perform rearrangement on coefficientvalues with respect to quantized residual values.

The rearrangement unit 160 may change coefficients in the form of atwo-dimensional block into coefficients in the form of a one-dimensionalvector through a coefficient scanning method. For example, therearrangement unit 160 may scan from a DC coefficient to a coefficientin a high frequency domain by using a zigzag scanning method so as tochange the coefficients into the form of a one-dimensional vector.According to a size and an intra prediction mode of a transform unit,rather than zigzag scanning, vertical directional scanning wherecoefficients in the form of a two-dimensional block are scanned in acolumn direction, or horizontal directional scanning where coefficientsin the form of two-dimensional block are scanned in a row direction maybe used. In other words, which scanning method among zigzag scanning,vertical directional scanning, and horizontal directional scanning isused may be determined according to a size and an intra prediction modeof a transform unit.

The entropy encoding unit 165 may perform entropy encoding on the basisof values calculated by the rearrangement unit 160. Entropy encoding mayuse various encoding methods, for example, exponential Golomb coding,context-adaptive variable length coding (CAVLC), or context-adaptivebinary arithmetic coding (CABAL).

The entropy encoding unit 165 may encode various types of information,such as information on a residual value coefficient and information on ablock type of a coding unit, information on a prediction mode,information on a partitioning unit, information on a prediction unit,information on a partitioning unit, information on a prediction unit andinformation on a transmission unit, information on a motion vector,information on a reference frame, information on a block interpolation,filtering information, etc. obtained from the rearrangement unit 160 andthe prediction units 120 and 125.

The entropy encoding unit 165 may entropy encode coefficients of acoding unit input from the rearrangement unit 160.

The dequantization unit 140 may perform dequantization on valuesquantized in the quantization unit 135, and the inverse-transform unit145 may perform inverse-transform on values transformed in the transformunit 130. A residual value generated by the dequantization unit 140 andthe inverse-transform unit 145 may be added with a prediction unitpredicted by a motion estimation unit, a motion compensation unit, orthe intra-prediction unit which are included in the prediction units 120and 125 so as to generate a reconstructed block.

The filter unit 150 may include at least one of a deblocking filter, anoffset correction unit, and an adaptive loop filter (ALF).

The deblocking filter may remove block distortion that occurs due toboundaries between blocks in a reconstructed picture. In order todetermine whether or not to perform deblocking, whether or not to applya deblocking filter to a current block may be determined on the basis ofpixels included in several rows and columns included in a block. When adeblocking filter is applied to a block, a strong filter or a weakfilter is applied according to required deblocking filtering strength.In addition, in applying a deblocking filter, when performing horizontaldirectional filtering and vertical directional filtering, horizontaldirectional filtering and vertical directional filtering may beconfigured to be processed in parallel.

The offset correction unit may correct an original image by an offset ina unit of a pixel with respect to an image for which deblocking isperformed. In order to perform offset correction on a specific picture,a method of applying a offset to a region which is determined afterpartitioning pixels of the image into the predetermined number ofregions, or a method of applying an offset according to edge informationof each pixel may be used.

Adaptive loop filtering (ALF) may be performed on the basis of a valueobtained by comparing a filtered reconstructed image with an originalimage. Pixels included in an image may be partitioned into predeterminedgroups, a filter to be applied to each of the groups may be determined,and filtering may be individually performed on each group. Informationon whether or not to apply ALF and may be transmitted for each codingunit (CU) for a luma signal, and a shape and a filter coefficient of anALF filter to be applied may vary on the basis of each block.Alternatively, an ALF filter having the same shape (fixed shape) may beapplied regardless of a feature of a block to which the filter will beapplied.

In the memory 155, a reconstructed block or picture calculated throughthe filter unit 150 may be stored. The stored reconstructed block orpicture may be provided to the prediction unit 120 or 125 whenperforming inter-prediction.

FIG. 2 is view showing a block diagram of an image decoding apparatus(decoder) according to an embodiment of the present disclosure.

Referring to FIG. 2, an image decoding apparatus 200 may include: anentropy decoding unit 210, a rearrangement unit 215, a dequantizationunit 220, an inverse-transform unit 225, prediction units 230 and 235, afilter unit 240, and a memory 245.

When an image bitstream is input from the encoder, the input bitstreammay be decoded according to an inverse process of the image encodingapparatus.

The entropy decoding unit 210 may perform entropy decoding according tothe inverse process of the entropy encoding by the entropy encoding unitof the image encoder. For example, in association with the methodsperformed by the image encoder apparatus, various methods, such asexponential Golomb coding, context-adaptive variable length coding(CAVLC), or context-adaptive binary arithmetic coding (CABAC) may beapplied.

The entropy decoding unit 210 may decode information on intra-predictionand inter-prediction performed by the encoder.

The rearrangement unit 215 may perform rearrangement on the bitstreamentropy decoded by the entropy decoding unit 210 on the basis of therearrangement method used in the encoder. Coefficients represented inthe form of a one-dimensional vector may be reconstructed and rearrangedinto coefficients in the form of a two-dimensional block. Therearrangement unit 215 may perform rearrangement through a method ofreceiving information related to coefficient scanning performed in theencoder and of inversely scanning on the basis of the scanning orderperformed in the encoder.

The dequantization unit 220 may perform dequantization on the basis of aquantization parameter received from the encoder and coefficient valuesof the rearranged block.

The inverse-transform unit 225 may perform, an inverse transform, thatis inverse DCT or inverse DST, against to a transform, that is DCT orDST, performed on the quantization result by the transform unit in theimage encoder. In this connection, a DCT transform core may include atleast one of DCT2 or DCT8, and a DST transform core may include DST7.Alternatively, when the transform is skipped in the image encoder, theinverse-transform also not be performed in the inverse-transform unit225. Inverse transform may be performed on the basis of a transmissionunit determined by the image encoder. The inverse transform unit 225 ofthe image decoder may selectively perform a transform method (forexample, DCT, or DST) according to multiple pieces of information, suchas a prediction method, a size of a current block, a predictiondirection, etc.

The prediction unit 230 or 235 may generate a prediction block on thebasis of information related to a prediction block received from theentropy decoding unit 210 and information on a previously decoded blockor picture received from the memory 245.

As described above, as the operation of the image encoder, in performingintra-prediction, when a prediction unit is identical in size with atransform unit, intra-prediction may be performed on the prediction uniton the basis of pixels positioned at the left, the top-left, and the topof the prediction unit. However, in performing intra-prediction, when aprediction unit is different in size with a transform unit,intra-prediction may be performed by using a reference pixel based onthe transform unit. In addition, intra-prediction using N×N partitioningmay be only used for the smallest coding unit.

The prediction units 230 and 235 may include a PU determination module,an inter-prediction unit, and an intra-prediction unit. The PUdetermination unit may receive various types of information, such asinformation on a prediction unit, information on a prediction mode of anintra-prediction method, information on a motion prediction of aninter-prediction method, etc. which are input from the entropy decodingunit 210, divide a prediction unit in a current coding unit, anddetermine whether inter-prediction or intra-prediction is performed onthe prediction unit. By using information required in inter-predictionof a current prediction unit received from the image encoder, theinter-prediction unit 230 may perform inter-prediction on the currentprediction unit on the basis of information on at least one of aprevious picture and a subsequent picture of a current picture includingthe current prediction unit. Alternatively, inter-prediction may beperformed on the basis of information on some pre-reconstructed regionsin a current picture including the current prediction unit.

In order to perform inter-prediction, which method among a skip mode, amerge mode, an AMVP mode, or an intra block copy mode is used as amotion prediction method for a prediction unit included in a coding unitmay be determined on the basis of the coding unit.

The intra prediction unit 235 may generate a prediction block on thebasis of information on a pixel within a current picture. When aprediction unit is a prediction unit for which intra-prediction has beenperformed, intra-prediction may be performed on the basis of informationon an intra-prediction mode of a prediction unit received from the imageencoder. The intra prediction unit 235 may include an adaptive intrasmoothing (AIS) filter, a reference pixel interpolation module, or a DCfilter. The AIS filter may perform filtering on a reference pixel of acurrent block, and whether to apply the filter may be determinedaccording to a prediction mode for a current prediction unit. Aprediction mode of the prediction unit and information on an AIS filterwhich are received from the image encoder may be used when performingAIS filtering on a reference pixel of a current block. When a predictionmode for the current block is a mode to which AIS filtering is notapplied, the AIS filter may not be applied.

When a prediction mode of a prediction unit is a prediction mode forwhich intra-prediction is performed on the basis of a pixel valueobtained by interpolating reference pixels, the reference pixelinterpolation unit may interpolate the reference pixels so as togenerate a reference pixel having a unit of an integer or less. When aprediction mode for a current prediction unit is a prediction mode wherea prediction block is generated without interpolating reference pixels,the reference pixels may not be interpolated. The DC filter may generatea prediction block through filtering when a prediction mode for acurrent block is a DC mode.

A reconstructed block or picture may be provided to the filter unit 240.The filter unit 240 may include a deblocking filter, an offsetcorrection module, and an ALF.

Information on whether or not a deblocking filter has been applied to acorresponding block or picture and information on whether a strongfilter or a weak filter is applied when the deblocking filter is appliedmay be received from the image encoder. The deblocking filter of theimage decoder may receive information on a deblocking filter from theimage encoder, and the image decoder may perform deblocking filtering ona corresponding block.

The offset correction unit may perform offset correction on areconstructed image on the basis of a type of offset correction,information on an offset value, etc. applied to an image when performingencoding.

The ALF may be applied to a coding unit on the basis of information onwhether or not to apply ALF, information on an ALF coefficient, etc.received from the encoder. The above ALF information may be provided bybeing included in a particular parameter set.

In the memory 245, a reconstructed picture or block may be stored so asto be used as a reference picture or reference block, and thereconstructed picture may be provided to an output unit.

FIG. 3 is a view showing a basic coding tree unit according to anembodiment of the present disclosure.

The largest coding block may be defined as a coding tree block. A singlepicture may be partitioned into a plurality of coding tree units (CTU).A CTU may be a coding unit of the largest size, and may be referred toas the largest coding unit (LCU). FIG. 3 is a view showing an examplewhere a single picture is partitioned into a plurality of CTUs.

A size of a CTU may be defined in a picture level or sequence level. Forthe same, information representing a size of a CTU may be signaledthrough a picture parameter set or sequence parameter set.

In an example, a size of a CTU for the entire picture within a sequencemay be set to 128×128. Alternatively, any one of 128×128 or 256×256 maybe determined as a size of a CTU in a picture level. In an example, aCTU may be set to have a size of 128×128 in a first picture, and a sizeof 256×256 in a second picture.

Coding blocks may be generated by partitioning a CTU. A coding blockrepresents a basic unit for performing encoding/decoding. In an example,prediction or transform may be performed for each coding block, or aprediction encoding mode may be determined for each coding block. Inthis connection, the prediction encoding mode represents a method ofgenerating a prediction image. In an example, a prediction encoding modemay include intra-prediction, inter-prediction, current picturereferencing (CPR), intra block copy (IBC) or combined prediction. For acoding block, a prediction block of the coding block may be generated byusing a prediction encoding mode of at least one of intra-prediction,inter-prediction, current picture referencing, or combined prediction.

Information representing a prediction encoding mode for a current blockmay be signaled in a bitstream. In an example, the information may be a1-bit flag representing whether a prediction encoding mode is an intramode or an inter mode. When a prediction encoding mode for a currentblock is determined as an inter mode, current picture referencing orcombined prediction may be available.

Current picture referencing is setting a current picture as a referencepicture and obtaining a prediction block of a current block from aregion that has been already encoded/decoded within a current picture.In this connection, the current picture means a picture including thecurrent block. Information representing whether or not current picturereferencing is applied to a current block may be signaled in abitstream. In an example, the information may be a 1-bit flag. When theflag is TRUE, a prediction encoding mode for a current block may bedetermined as current picture referencing, and when the flag is FALSE, aprediction encoding mode for a current block may be determined asinter-prediction.

Alternatively, a prediction encoding mode for a current block may bedetermined on the basis of a reference picture index. In an example,when a reference picture index indicates a current picture, a predictionencoding mode for a current block may be determined as current picturereferencing. When a reference picture index indicates a picture otherthan a current picture, a prediction encoding mode for a current blockmay be determined as inter-prediction. In other words, current picturereferencing is a prediction method using information on a region thathas been already encoded/decoded within a current picture, andinter-prediction is a prediction method using information on anotherpicture that has been already encoded/decoded.

Combined prediction represents a combined encoding mode combining atleast two of intra-prediction, inter-prediction, and current picturereferencing. In an example, when combined prediction is applied, a firstprediction block may be generated on the basis of any one ofintra-prediction, inter-prediction or current picture referencing, and asecond prediction block may be generated on the basis of another. When afirst prediction block and a second prediction block are generated, afinal prediction block may be generated by calculating an average orweighted sum of the first prediction block and the second predictionblock. Information representing whether or not to apply combinedprediction to a current block may be signaled in a bitstream. Theinformation may be a 1-bit flag.

FIG. 4 is a view showing various partitioning types a coding block.

A coding block may be partitioned into a plurality of coding blocks onthe basis of quad-tree partitioning, binary-tree partitioning or ternarytree partitioning. The partitioned coding block may be partitioned againinto a plurality of coding blocks on the basis of quad-treepartitioning, binary-tree partitioning or ternary tree partitioning.

Quad-tree partitioning represents a method of partitioning a currentblock into four blocks. As a result of quad-tree partitioning, a currentblock may be partitioned into four square partitions (refer to“SPLIT_QT” of FIG. 4 (a)).

Binary-tree partitioning represents a method of partitioning a currentblock into two blocks. Partitioning a current block into two blocksalong a vertical direction (that is, using a vertical line across thecurrent block) may be referred to vertical directional binary-treepartitioning, and partitioning a current block into two blocks along ahorizontal direction (that is, using a horizontal line across thecurrent block) may be referred to as horizontal directional binary-treepartitioning. As a result of binary-tree partitioning, a current blockmay be partitioned into two non-square partitions. “SPLIT_BT_VER” ofFIG. 4 (b) is a view showing a result of vertical directionalbinary-tree partitioning, and “SPLIT_BT_HOR” of FIG. 4 (c) is a viewshowing a result of horizontal directional binary-tree partitioning.

Ternary-tree partitioning represents a method of partitioning a currentblock into three blocks. Partitioning a current block into three blocksalong a vertical direction (that is, using two vertical lines across thecurrent block) may be referred to vertical directional ternary-treepartitioning, and partitioning a current block into three blocks along ahorizontal direction (that is, using two horizontal lines across thecurrent block) may be referred to as horizontal directional ternary-treepartitioning. As a result of ternary-tree partitioning, a current blockmay be partitioned into three non-square partitions. In this connection,a width/height of a partition positioned at the center of a currentblock may be twice than a width/height of other partitions.“SPLIT_TT_VER” of FIG. 4 (d) is a view showing a result of verticaldirectional ternary-tree partitioning, and “SPLIT_TT_HOR” of FIG. 4 (e)is a view showing a result of horizontal directional ternary-treepartitioning.

The number of partitioning times of a CTU may be defined as apartitioning depth. The maximum partitioning depth of a CTU may bedetermined in a sequence or picture level. Accordingly, the maximumpartitioning depth of a CTU may vary on the basis of a sequence orpicture.

Alternatively, the maximum partitioning depth may be independentlydetermined for each partitioning method. In an example, the maximumpartitioning depth where quad-tree partitioning is allowed may differfrom the maximum partitioning depth where binary-tree partitioningand/or ternary-tree partitioning is allowed.

The encoder may signal information representing at least one of apartitioning type and a partitioning depth of a current block in abitstream. The decoder may determine a partitioning type and apartitioning depth of a CTU on the basis of the information obtained byparsing a bitstream.

FIG. 5 is a view of an example showing an aspect of partitioning a CTU.

Partitioning a coding block by using quad-tree partitioning, binary-treepartitioning and/or ternary-tree partitioning may be referred to asmulti-tree partitioning.

Coding blocks generated by partitioning a coding block by applyingmulti-tree partitioning may be referred to child coding blocks. When apartitioning depth of a coding block is k, a partitioning depth of childcoding blocks is set to k+1.

To the contrary, for coding blocks having a partitioning depth of k+1, acoding block having a partitioning depth of k may be referred to as aparent coding block.

A partitioning type of a current coding block may be determined on thebasis of at least one of a partitioning type of a parent coding blockand a partitioning type of a neighboring coding block. In thisconnection, the neighboring coding block may be a block adjacent to acurrent coding block, and include at least one of an top neighboringblock, a left neighboring block, or a neighboring block adjacent to thetop-left corner of the current coding block. In this connection, thepartitioning type may include whether or not to apply quad-treepartitioning, whether or not to apply binary-tree partitioning, adirection of binary-tree partitioning, whether or not to applyternary-tree partitioning, or a direction of ternary-tree partitioning.

In order to determine a partitioning type of a coding block, informationrepresenting whether or not a coding block is partitioned may besignaled in a bitstream. The information is a 1-bit flag of“split_cu_flag”, and when the flag is TRUE, it may represent that acoding block is partitioned by a multi tree partitioning method.

When split_cu_flag is TRUE, information representing whether or not acoding block is partitioned by quad-tree partitioning may be signaled ina bitstream. The information is a 1-bit flag of split_qt_flag, and whenthe flag is TRUE, a coding block may be partitioned into four blocks.

In an example, in an example shown in FIG. 5, a CTU is partitioned byquad-tree partitioning, and thus four coding blocks having apartitioning depth of 1 are generated. In addition, it is shown thatquad-tree partitioning is applied again to the first coding block andthe fourth coding block among four coding blocks generated by quad-treepartitioning. As a result, four coding blocks having a partitioningdepth of 2 may be generated.

In addition, by applying again quad-tree partitioning to a coding blockhaving a partitioning depth of 2, a coding block having a partitioningdepth of 3 may be generated.

When quad-tree partitioning is not applied to a coding block, whether toperform binary-tree partitioning or ternary-tree partitioning for thecoding block may be determined according to at least one of a size ofthe coding block, whether or not the coding block is positioned at apicture boundary, the maximum partitioning depth, or a partitioning typeof a neighboring block. When it is determined to perform binary-treepartitioning or ternary-tree partitioning for the coding block,information representing a partitioning direction may be signaled in abitstream. The information may be a 1-bit flag ofmtt_split_cu_vertical_flag. Whether a partitioning direction is avertical direction or a horizontal direction may be determined on thebasis of the flag. Additionally, information representing which one ofbinary-tree partitioning or ternary-tree partitioning is applied to thecoding block may be signaled in a bitstream. The information may be a1-bit flag of mtt_split_cu_binary_flag. Whether binary-tree partitioningis applied to the coding block or ternary-tree partitioning is appliedto the coding block may be determined on the basis of the flag.

In an example, in an example shown in FIG. 5, vertical directionalbinary-tree partitioning is applied to a coding block having apartitioning depth of 1, vertical directional ternary-tree partitioningis applied to a left coding block among coding blocks generated by thepartitioning, and vertical directional binary-tree partitioning isapplied to a right coding block.

Inter-prediction is a prediction encoding mode predicting a currentblock by using information on a previous picture. In an example, a block(hereinafter, collocated block) at the same position with a currentblock within a previous picture may be set as a prediction block of thecurrent block. Hereinafter, a prediction block generated on the basis ofa collocated block of the current block may be referred to as acollocated prediction block.

To the contrary, when an object present in a previous picture has movedto another position in a current picture, a current block may beeffectively predicted by using motions of the object. For example, whena motion direction and a size of the object is determined by comparing aprevious picture with a current picture, a prediction block (orprediction image) of the current block may be generated according tomotion information of the objects. Hereinafter, a prediction blockgenerated by using motion information may be referred to as a motionprediction block.

A residual block may be generated by subtracting a prediction block froma current block. In this connection, in case where an object moves,energy of a residual block may be reduced by using a motion predictionblock rather than using a collocated prediction block, and thuscompression performance of the residual block may be improved.

As above, generating a prediction block by using motion information maybe referred to as motion estimation prediction. In the mostinter-prediction, a prediction block may be generated on the basis ofmotion compensation prediction.

Motion information may include at least one of a motion vector, areference picture index, a prediction direction, and a bidirectionalweighting factor index. A motion vector represents a motion direction ofan object and a magnitude. A reference picture index specifies areference picture of a current block among reference pictures includedin a reference picture list. A prediction direction indicates any one ofuni-directional L0 prediction, uni-directional L1 prediction, orbi-directional prediction (L0 prediction and L1 prediction). At leastone of L0 directional motion information and L1 directional motioninformation may be used according to a prediction direction of a currentblock. A bidirectional weighting factor index specifies a weightingfactor applied to an L0 prediction block and a weighting factor appliedto an L1 prediction block.

FIG. 6 is a flow diagram of an inter-prediction method according to theembodiment of the present disclosure.

In reference to FIG. 6, an inter-prediction method includes determiningan inter-prediction mode for a current block S601, obtaining motioninformation of the current block according to the determinedinter-prediction mode S602, and performing motion compensationprediction for a current block on the basis of the obtained motioninformation S603.

In this connection, the inter-prediction mode may represent variousmethods for determining motion information of a current block, andinclude an inter-prediction mode using translation motion information,an inter-prediction mode using affine motion information. In an example,an inter-prediction mode using translation motion information mayinclude a merge mode and a motion vector prediction mode, and aninter-prediction mode using affine motion information may include anaffine merge mode and an affine motion vector prediction mode. Motioninformation on a current block may be determined on the basis of aneighboring block neighboring the current block or information obtainedby parsing a bitstream.

Motion information of a current block may be derived from motioninformation of another block. In this connection, another block may be ablock encoded/decoded by inter prediction previous to the current block.Setting motion information of a current block to be the same as motioninformation of another block may be defined as a merge mode. Also,setting a motion vector of another block as a prediction value of amotion vector of the current block may be defined as a motion vectorprediction mode.

FIG. 7 is a flow diagram of a process deriving the motion information ofa current block under a merge mode.

The merge candidate of a current block may be derived S701. The mergecandidate of a current block may be derived from a block encoded/decodedby inter-prediction prior to a current block.

FIG. 8 is a diagram illustrating candidate blocks used to derive a mergecandidate.

The candidate blocks may include at least one of neighboring blocksincluding a sample adjacent to a current block or non-neighboring blocksincluding a sample non-adjacent to a current block. Hereinafter, samplesdetermining candidate blocks are defined as base samples. In addition, abase sample adjacent to a current block is referred to as a neighboringbase sample and a base sample non-adjacent to a current block isreferred to as a non-neighboring base sample.

A neighboring base sample may be included in a neighboring column of aleftmost column of a current block or a neighboring row of an uppermostrow of a current block. In an example, when the coordinate of a left-topsample of a current block is (0,0), at least one of a block including abase sample at a position of (−1, H−1), (W−1, −1), (W, −1), (−1, H) or(−1, −1) may be used as a candidate block. In reference to a diagram,the neighboring blocks of index 0 to 4 may be used as candidate blocks.

A non-neighboring base sample represents a sample that at least one of ax-axis distance or a y-axis distance with a base sample adjacent to acurrent block has a predefined value. In an example, at least one of ablock including a base sample that a x-axis distance with a left basesample is a predefined value, a block including a non-neighboring samplethat a y-axis distance with a top base sample is a predefined value or ablock including a non-neighboring sample that a x-axis distance and ay-axis distance with a left-top base sample are a predefined value maybe used as a candidate block. A predefined value may be a natural numbersuch as 4, 8, 12, 16, etc. In reference to a diagram, at least one ofblocks in an index 5 to 26 may be used as a candidate block.

A sample not positioned on the same vertical, horizontal or diagonalline as a neighboring base sample may be set as a non-neighboring basesample.

Hereinafter, a candidate block including a neighboring base sample amongcandidate blocks is referred to as a neighboring block and a candidateblock including a non-neighboring base sample is referred to as anon-neighboring block.

When a distance between a current block and a candidate block is equalto or greater than a threshold value, the candidate block may be set tobe unavailable as a merge candidate. The threshold value may bedetermined based on a size of a coding tree unit. In an example, athreshold value may be set as a height of a coding tree unit(ctu_height) or a value adding or subtracting an offset to or from aheight of a coding tree unit (ctu_height±N). As an offset N is apredefined value in an encoding device and a decoding device, it may beset to be 4, 8, 16, 32 or ctu_height.

When a difference between a y-axis coordinate of a current block and ay-axis coordinate of a sample included in a candidate block is greaterthan a threshold value, a candidate block may be determined to beunavailable as a merge candidate.

Alternatively, a candidate block not belonging to the same coding treeunit as a current block may be set to be unavailable as a mergecandidate. In an example, when a base sample is out of an upper boundaryof a coding tree unit to which a current block belongs, a candidateblock including the base sample may be set to be unavailable as a mergecandidate.

When an upper boundary of a current block adjoins an upper boundary of acoding tree unit, a plurality of candidate blocks may be determined tobe unavailable as a merge candidate, so the encoding/decoding efficiencyof a current block may be reduced. To solve such a problem, it may beset that the number of candidate blocks positioned at the left of acurrent block is greater than the number of candidate blocks positionedat the top of a current block.

FIG. 9 is a diagram illustrating candidate blocks used to derive a mergecandidate.

As in an example shown in FIG. 9, top blocks belonging to N block rowsat the top of a current block and left blocks belonging to M blockcolumns at the left of a current block may be set as candidate blocks.In this case, the number of left candidate blocks may be set to begreater than the number of top candidate blocks by setting N to begreater than M.

In an example, a difference between a y-axis coordinate of a base samplein a current block and a y-axis coordinate of a top block which may beused as a candidate block may be set not to exceed N times the height ofa current block. In addition, a difference between an x-axis coordinateof a base sample in a current block and an x-axis coordinate of a leftblock which may be used as a candidate block may be set not to exceed Mtimes a width of a current block.

In an example, an example shown in FIG. 9 showed that blocks belongingto two block rows at the top of a current block and blocks belonging tofive left block columns at the left of a current block are set ascandidate blocks.

A merge candidate may be derived from a temporal neighboring blockincluded in a picture different from a current block. In an example, amerge candidate may be derived from a collocated block included in acollocated picture. Any one of reference pictures included in areference picture list may be set as a collocated picture. Indexinformation identifying a collocated picture among reference picturesmay be signaled in a bitstream. Alternatively, a reference picture witha predefined index among reference pictures may be determined as acollocated picture.

The motion information of a merge candidate may be set the same as themotion information of a candidate block. In an example, at least one ofa motion vector, a reference picture index, a prediction direction or abidirectional weight index of a candidate block may be set as the motioninformation of a merge candidate.

A merge candidate list including a merge candidate may be generatedS702.

The index of merge candidates in a merge candidate list may be assignedaccording to the predetermined order. In an example, an index may beassigned in the order of a merge candidate derived from a leftneighboring block, a merge candidate derived from a top neighboringblock, a merge candidate derived from a right-top neighboring block, amerge candidate derived from a left-bottom neighboring block, a mergecandidate derived from a left-top neighboring block and a mergecandidate derived from a temporal neighboring block.

When a plurality of merge candidates are included in a merge candidate,at least one of a plurality of merge candidates may be selected S703.Concretely, information for specifying any one of a plurality of mergecandidates may be signaled in a bitstream. In an example, information,merge_idx, representing an index of any one of merge candidates includedin a merge candidate list may be signaled in a bitstream.

When the number of merge candidates included in a merge candidate listis less than the threshold, a motion information candidate included in amotion information table may be added to a merge candidate list as amerge candidate. In this connection, the threshold may be the maximumnumber of merge candidates which may be included in a merge candidatelist or a value in which an offset is subtracted from the maximum numberof merge candidates. An offset may be a natural number such as 1 or 2,etc.

A motion information table includes a motion information candidatederived from a block encoded/decoded based on inter-prediction in acurrent picture. In an example, the motion information of a motioninformation candidate included in a motion information table may be setthe same as the motion information of a block encoded/decoded based oninter-prediction. In this connection, motion information may include atleast one of a motion vector, a reference picture index, a predictiondirection or a bidirectional weight index.

A motion information candidate included in a motion information tablealso can be referred to as a inter region merge candidate or aprediction region merge candidate.

The maximum number of a motion information candidate which may beincluded in a motion information table may be predefined in an encoderand a decoder. In an example, the maximum number of a motion informationcandidate which may be included in a motion information table may be 1,2, 3, 4, 5, 6, 7, 8 or more (e.g. 16).

Alternatively, information representing the maximum number of a motioninformation candidate which may be included in a motion informationtable may be signaled in a bitstream. The information may be signaled ina sequence, a picture or a slice level. The information may representthe maximum number of a motion information candidate which may beincluded in a motion information table. Alternatively, the informationmay represent difference between the maximum number of a motioninformation candidate which may be included in a motion informationtable and the maximum number of a merge candidate which may be includedin a merge candidate list.

Alternatively, the maximum number of a motion information candidatewhich may be included in a motion information table may be determinedaccording to a picture size, a slice size or a coding tree unit size.

A motion information table may be initialized in a unit of a picture, aslice, a tile, a brick, a coding tree unit or a coding tree unit line (arow or a column). In an example, when a slice is initialized, a motioninformation table is also initialized thus a motion information tablemay not include any motion information candidate.

Alternatively, information representing whether a motion informationtable will be initialized may be signaled in a bitstream. Theinformation may be signaled in a slice, a tile, a brick or a blocklevel. Until the information indicates the initialization of a motioninformation table, a pre-configured motion information table may beused.

Alternatively, information on an initial motion information candidatemay be signaled in a picture parameter set or a slice header. Although aslice is initialized, a motion information table may include an initialmotion information candidate. Accordingly, an initial motion informationcandidate may be used for a block which is the first encoding/decodingtarget in a slice.

Alternatively, a motion information candidate included in the motioninformation table of a previous coding tree unit may be set as aninitial motion information candidate. In an example, a motioninformation candidate with the smallest index or with the largest indexamong motion information candidates included in the motion informationtable of a previous coding tree unit may be set as an initial motioninformation candidate.

Blocks are encoded/decoded in the order of encoding/decoding, and blocksencoded/decoded based on inter-prediction may be sequentially set as amotion information candidate in the order of encoding/decoding.

FIG. 10 is a diagram to explain the update aspect of a motioninformation table.

For a current block, when inter-prediction is performed S1001, a motioninformation candidate may be derived based on a current block S1002. Themotion information of a motion information candidate may be set the sameas that of a current block.

When a motion information table is empty S1003, a motion informationcandidate derived based on a current block may be added to a motioninformation table S1004.

When a motion information table already includes a motion informationcandidate S1003, a redundancy check for the motion information of acurrent block (or, a motion information candidate derived based on it)may be performed S1005. A redundancy check is to determine whether themotion information of a pre-stored motion information candidate in amotion information table is the same as the motion information of acurrent block. A redundancy check may be performed for all pre-storedmotion information candidates in a motion information table.Alternatively, a redundancy check may be performed for motioninformation candidates with an index over or below the threshold amongpre-stored motion information candidates in a motion information table.Alternatively, a redundancy check may be performed for the predefinednumber of motion information candidates. In an example, 2 motioninformation candidates with smallest indexes or with largest indexes maybe determined as targets for a redundancy check.

When a motion information candidate with the same motion information asa current block is not included, a motion information candidate derivedbased on a current block may be added to a motion information tableS1008. Whether motion information candidates are identical may bedetermined based on whether the motion information (e.g. a motionvector/a reference picture index, etc.) of motion information candidatesis identical.

In this connection, when the maximum number of motion informationcandidates are already stored in a motion information table S1006, theoldest motion information candidate may be deleted S1007 and a motioninformation candidate derived based on a current block may be added to amotion information table S1008. In this connection, the oldest motioninformation candidate may be a motion information candidate with thelargest or the smallest index.

Motion information candidates may be identified by respective index.When a motion information candidate derived from a current block isadded to a motion information table, the smallest index (e.g. 0) may beassigned to the motion information candidate and indexes of pre-storedmotion information candidates may be increased by 1. In this connection,When the maximum number of motion information candidates are alreadystored in a motion information table, a motion information candidatewith the largest index is removed.

Alternatively, when a motion information candidate derived from acurrent block is added to a motion information table, the largest indexmay be assigned to the motion information candidate. In an example, whenthe number of pre-stored motion information candidates in a motioninformation table is less than the maximum value, an index with the samevalue as the number of pre-stored motion information candidates may beassigned to the motion information candidate. Alternatively, when thenumber of pre-stored motion information candidates in a motioninformation table is equal to the maximum value, an index subtracting 1from the maximum value may be assigned to the motion informationcandidate. Alternatively, a motion information candidate with thesmallest index is removed and the indexes of residual pre-stored motioninformation candidates are decreased by 1.

FIG. 11 is a diagram showing the update aspect of a motion informationtable.

It is assumed that as a motion information candidate derived from acurrent block is added to a motion information table, the largest indexis assigned to the motion information candidate. In addition, it isassumed that the maximum number of a motion information candidate isalready stored in a motion information table.

When a motion information candidate HmvpCand[n+1] derived from a currentblock is added to a motion information table HmvpCandList, a motioninformation candidate HmvpCand[0] with the smallest index amongpre-stored motion information candidates may be deleted and indexes ofresidual motion information candidates may be decreased by 1. Inaddition, the index of a motion information candidate HmvpCand[n+1]derived from a current block may be set to the maximum value (for anexample shown in FIG. 11, n).

When a motion information candidate identical to a motion informationcandidate derived based on a current block is prestored S1005, a motioninformation candidate derived based on a current block may not be addedto a motion information table S1009.

Alternatively, while a motion information candidate derived based on acurrent block is added to a motion information table, a pre-storedmotion information candidate identical to the motion informationcandidate may be removed. In this case, it causes the same effect aswhen the index of a pre-stored motion information candidate is newlyupdated.

FIG. 12 is a diagram showing an example in which the index of apre-stored motion information candidate is updated.

When the index of a pre-stored motion information candidate identical toa motion information candidate mvCand derived from a current block ishIdx, the pre-stored motion information candidate may be removed and theindex of motion information candidates with an index larger than hIdxmay be decreased by 1. In an example, an example shown in FIG. 12 showedthat HmvpCand[2] identical to mvCand is deleted in a motion informationtable HvmpCandList and an index from HmvpCand[3] to HmvpCand[n] isdecreased by 1.

And, a motion information candidate mvCand derived based on a currentblock may be added to the end of a motion information table.

Alternatively, an index assigned to a pre-stored motion informationcandidate identical to a motion information candidate derived based on acurrent block may be updated. For example, the index of a pre-storedmotion information candidate may be changed to the minimum value or themaximum value.

The motion information of blocks included in a predetermined region maybe set not to be added to a motion information table. In an example, amotion information candidate derived based on the motion information ofa block included in a merge processing region may not be added to amotion information table. Since the encoding/decoding order for blocksincluded in a merge processing region is not defined, it is improper touse motion information of any one of them for the inter-prediction ofanother of them. Accordingly, motion information candidates derivedbased on blocks included in a merge processing region may not be addedto a motion information table.

Alternatively, the motion information of a block smaller than a presetsize may be set not to be added to a motion information table. In anexample, a motion information candidate derived based on the motioninformation of a coding block whose width or height is smaller than 4 or8 or the motion information of a 4×4 sized coding block may not be addedto a motion information table.

When motion compensation prediction is performed per sub-block basis, amotion information candidate may be derived based on the motioninformation of a representative sub-block among a plurality ofsub-blocks included in a current block. In an example, when a sub-blockmerge candidate is used for a current block, a motion informationcandidate may be derived based on the motion information of arepresentative sub-block among sub-blocks.

The motion vector of sub-blocks may be derived in the following order.First, any one of merge candidates included in the mere candidate listof a current block may be selected and an initial shift vector(shVector) may be derived based on the motion vector of a selected mergecandidate. And, a shift sub-block that a base sample is at a position of(xColSb, yColSb) may be derived by adding an initial shift vector to theposition (xSb, ySb) of the base sample of each sub-block in a codingblock (e.g. a left-top sample or a center sample). The below Equation 1shows a formula for deriving a shift sub-block.(xColSb,yColSb)=(xSb+shVector[0]>>4,ySb+shVector[1]>>4)  [Equation 1]

Then, the motion vector of a collocated block corresponding to thecenter position of a sub-block including (xColSb, yColSb) may be set asthe motion vector of a sub-block including (xSb, ySb).

A representative sub-block may mean a sub-block including the a top-leftsample, a central sample, a bottom-right sample, a top-right sample or abottom-left sample of a current block.

FIG. 13 is a diagram showing the position of a representative sub-block.

FIG. 13 (a) shows an example in which a sub-block positioned at theleft-top of a current block is set as a representative sub-block andFIG. 13 (b) shows an example in which a sub-block positioned at thecenter of a current block is set as a representative sub-block. Whenmotion compensation prediction is performed in a basis of a sub-block,the motion information candidate of a current block may be derived basedon the motion vector of a sub-block including the left-top sample of acurrent block or including the central sample of a current block.

Based on the inter-prediction mode of a current block, it may bedetermined whether a current block will be used as a motion informationcandidate. In an example, a block encoded/decoded based on an affinemotion model may be set to be unavailable as a motion informationcandidate. Accordingly, although a current block is encoded/decoded byinter-prediction, a motion information table may not be updated based ona current block when the inter-prediction mode of a current block is anaffine prediction mode.

Alternatively, based on at least one of a motion vector resolution of acurrent block, whether a merge offset encoding method is applied,whether combined prediction is applied or whether triangularpartitioning is applied, whether a current block will be used as amotion information candidate may be determined. In an example, a currentblock may be set to be unavailable as a motion information candidate inat least one of a case when a motion information resolution of a currentblock is equal to or greater than 2 integer-pel, a case when combinedprediction is applied to a current block or a case when a merge offsetencoding method is applied to a current block.

Alternatively, a motion information candidate may be derived based on atleast one sub-block vector of a sub-block included in a blockencoded/decoded based on an affine motion model. In an example, a motioninformation candidate may be derived by using a sub-block positioned atthe left-top, the center or the right-top of a current block.Alternatively, the average value of the sub-block vectors of a pluralityof sub-blocks may be set as the motion vector of a motion informationcandidate.

Alternatively, a motion information candidate may be derived based onthe average value of the affine seed vectors of a block encoded/decodedbased on an affine motion model. In an example, at least one average ofthe first affine seed vector, the second affine seed vector or the thirdaffine seed vector of a current block may be set as the motion vector ofa motion information candidate.

Alternatively, a motion information table may be configured perinter-prediction mode. In an example, at least one of a motioninformation table for a block encoded/decoded by an intra block copy, amotion information table for a block encoded/decoded based on atranslation motion model or a motion information table for a blockencoded/decoded based on an affine motion model may be defined.According to the inter-prediction mode of a current block, any one of aplurality of motion information tables may be selected.

FIG. 14 shows an example in which a motion information table isgenerated per inter-prediction mode.

When a block is encoded/decoded based on a non-affine motion model, amotion information candidate mvCand derived based on the block may beadded to a non-affine motion information table HmvpCandList. On theother hand, when a block is encoded/decoded based on an affine motionmodel, a motion information candidate mvAfCand derived based on theabove model may be added to an affine motion information tableHmvpCandList.

The affine seed vectors of the above block may be stored in a motioninformation candidate derived from a block encoded/decoded based on anaffine motion model. Accordingly, the motion information candidate maybe used as a merge candidate for deriving the affine seed vectors of acurrent block.

Alternatively, a motion information table may be configured per motionvector resolution. In an example, at least one of a motion informationtable for storing motion information that a motion vector resolution isa 1/16 pel, a motion information table for storing motion informationthat a motion vector resolution is a ¼ pel, a motion information tablefor storing motion information that a motion vector resolution is a ½pel, a motion information table for storing motion information that amotion vector resolution is an integer-pel or a motion information tablefor storing motion information that a motion vector resolution is a 4integer-pel may be defined.

FIG. 15 shows an example in which a motion information table isgenerated per motion vector resolution.

When a motion vector resolution of a block has a ¼ pel, the motioninformation of a block, mvCand, may be stored in a quarter-pel motioninformation table HmvpQPCandList. On the other hand, when a motionvector resolution of a block has an integer-pel, the motion informationof a block, mvCand, may be stored in an integer-pel motion informationtable HmvpIPCandList. When a motion vector resolution of a block has a 4integer-pel, the motion information of a block, mvCand, may be stored ina 4 integer-pel motion information table Hmvp4IPCandList.

Based on a motion vector resolution of a current block, a mergecandidate of a current block may be derived by selecting a motioninformation table. In an example, when a motion vector resolution of acurrent block is a ¼ pel, a merge candidate of a current block may bederived by using a quarter-pel motion information table HmvpQPCandList.On the other hand, when a motion vector resolution of a current block isan integer-pel, a merge candidate of a current block may be derived byusing an integer-pel motion information table HmvpIPCandList.

Alternatively, the motion information of a block to which a merge offsetencoding method is applied may be stored in a separate motioninformation table.

FIG. 16 shows an example in which the motion information of a block towhich a merge offset encoding method is applied is stored in a separatemotion information table.

When a merge offset vector encoding method is not applied to a block,the motion information of a block, mvCand, may be stored in a motioninformation table HmvpCandList. On the other hand, when a merge offsetvector encoding method is applied to a block, the motion information ofa block, mvCand, may not be stored in a motion information tableHmvpCandList, and may be stored in a merge offset motion informationtable HmvpMMVDCandList.

Based on whether a merge offset vector encoding method is applied to acurrent block, a motion information table may be selected. In anexample, when a merge offset encoding method is not applied to a currentblock, a merge candidate of a current block may be derived by using amotion information table HmvpCandList. On the other hand, when a mergeoffset encoding method is applied to a current block, a merge candidateof a current block may be derived by using a merge offset motioninformation table HmvpMMVDCandList.

An additional motion information table may be defined in addition to thedescribed motion information table. A long-term motion information table(hereinafter, referred to as the second motion information table) may bedefined in addition to the above-described motion information table(hereinafter, referred to as the first motion information table). Inthis connection, a long-term motion information table includes long-termmotion information candidates.

When both the first motion information table and the second motioninformation table are empty, first, a motion information candidate maybe added to the second motion information table. After the number ofmotion information candidates available for the second motioninformation table reaches the maximum number, a motion informationcandidate may be added to the first motion information table.

Alternatively, one motion information candidate may be added to both thesecond motion information table and the first motion information table.

In this connection, a second motion information table which is fullyfilled may not perform an update any more. Alternatively, when a decodedregion in a slice is over a predetermined ratio, the second motioninformation table may be updated. Alternatively, the second motioninformation table may be updated per N coding tree unit line.

On the other hand, the first motion information table may be updatedwhenever an encoded/decoded block is generated by inter-prediction. But,a motion information candidate added to the second motion informationtable may be set not to be used to update the first motion informationtable.

Information for selecting any one of the first motion information tableor the second motion information table may be signaled in a bitstream.When the number of a merge candidate included in a merge candidate listis less than the threshold, motion information candidates included in amotion information table indicated by the information may be added to amerge candidate list as a merge candidate.

Alternatively, a motion information table may be selected based on asize of a current block, a shape of the current block, aninter-prediction mode of the current block, whether bidirectionalprediction is applied to the current block, whether a motion vector isrefined or whether a triangular partitioning is applied to the currentblock.

Alternatively, when the number of merge candidates included in a mergecandidate list is less than the maximum number even though a motioninformation candidate included in the first motion information table isadded, a motion information candidate included in the second motioninformation table may be added to a merge candidate list.

FIG. 17 is a diagram showing an example in which a motion informationcandidate included in a long-term motion information table is added to amerge candidate list.

In case that the number of a merge candidate included in a mergecandidate list is less than the maximum number, a motion informationcandidate included in the first motion information table HmvpCandListmay be added to a merge candidate list. In When the number of a mergecandidate included in the merge candidate list is less than the maximumnumber even though motion information candidates included in the firstmotion information table is added to a merge candidate list, a motioninformation candidate included in a long-term motion information tableHmvpLTCandList may be added to the merge candidate list.

A motion information candidate may be set to include additionalinformation except for motion information. In an example, at least oneof a size, shape or partition information of a block may be additionallystored in a motion information candidate. When the merge candidate listof a current block is configured, only motion information candidatewhose a size, shape or partition information is identical or similar toa current block among motion information candidates may be used or amotion information candidate whose a size, shape or partitioninformation is identical or similar to a current block may be added to amerge candidate list in advance. Alternatively, a motion informationtable may be generated per block size, shape or partition information.The merge candidate list of a current block may be configured by using amotion information table matching the shape, size or partitioninformation of a current block among a plurality of motion informationtables.

When the number of a merge candidate included in the merge candidatelist of a current block is less than the threshold, a motion informationcandidate included in a motion information table may be added to a mergecandidate list as a merge candidate. The additional process is performedin the order reflecting sorted order of indexes of motion informationcandidates in ascending or descending order. In an example, a motioninformation candidate with the largest index may be first added to themerge candidate list of a current block.

When a motion information candidate included in a motion informationtable is added to a merge candidate list, a redundancy check between amotion information candidate and pre-stored merge candidates in themerge candidate list may be performed. As a result of a redundancycheck, a motion information candidate with the same motion informationas a pre-stored merge candidate may not be added to the merge candidatelist.

A redundancy check may be performed only for a part of motioninformation candidates included in a motion information table. In anexample, a redundancy check may be performed only for a motioninformation candidate with an index over or below the threshold.Alternatively, a redundancy check may be performed only for N motioninformation candidates with the largest index or the smallest index.Alternatively, a redundancy check may be performed only for a part ofpre-stored merge candidates in a merge candidate list. In an example, aredundancy check may be performed only for a merge candidate whose indexis over or below the threshold or a merge candidate derived from a blockat a specific position. In this connection, a specific position mayinclude at least one of the left neighboring block, the top neighboringblock, the right-top neighboring block or the left-bottom neighboringblock of a current block.

FIG. 18 is a diagram showing an example in which a redundancy check isperformed only for a part of merge candidates.

When a motion information candidate HmvpCand[j] is added to a mergecandidate list, a redundancy check with 2 merge candidates with thelargest index, mergeCandList[NumMerge−2] and mergeCandList[NumMerge−1],may be performed for a motion information candidate. In this connection,NumMerge may show the number of an available spatial merge candidate anda temporal merge candidate.

Unlike a shown example, when a motion information candidate HmvpCand[j]is added to a merge candidate list, a redundancy check with 2 mergecandidates with the smallest index may be performed for a motioninformation candidate. For example, it may be checked whethermergeCandList[0] and mergeCandList[1] are identical to HmvpCand[j].

Alternatively, a redundancy check may be performed only for a mergecandidate derived from a specific position. In an example, a redundancycheck may be performed for at least one of a merge candidate derivedfrom a neighboring block positioned at the left of a current block or atthe top of a current block. When there is no merge candidate derivedfrom a specific position in a merge candidate list, a motion informationcandidate may be added to a merge candidate list without a redundancycheck.

When a motion information candidate HmvpCand[j] is added to a mergecandidate list, a redundancy check with 2 merge candidates with thelargest index, mergeCandList[NumMerge−2] and mergeCandList[NumMerge−1],may be performed for a motion information candidate. In this connection,NumMerge may show the number of an available spatial merge candidate anda temporal merge candidate.

A redundancy check with a merge candidate may be performed only for apart of motion information candidates. In an example, a redundancy checkmay be performed only for N motion information candidates with a largeor a small index among motion information candidates included in amotion information table. In an example, a redundancy check may beperformed only for motion information candidates with an index that thenumber and difference of motion information candidates included in amotion information table are below the threshold. When the threshold is2, a redundancy check may be performed only for 3 motion informationcandidates with the largest index value among motion informationcandidates included in a motion information table. A redundancy checkmay be omitted for motion information candidates except for the above 3motion information candidates. When a redundancy check is omitted, amotion information candidate may be added to a merge candidate listregardless of whether the same motion information as a merge candidateis exist or not.

Conversely, a redundancy check is set to be performed only for motioninformation candidates with an index that the number and difference ofmotion information candidates included in a motion information table areover the threshold.

The number of a motion information candidate that a redundancy check isperformed may be redefined in an encoder and a decoder. In an example,the threshold may be an integer such as 0, 1 or 2.

Alternatively, the threshold may be determined based on at least one ofthe number of a merge candidate included in a merge candidate list orthe number of motion information candidates included in a motioninformation table.

When a merge candidate identical to the first motion informationcandidate is found, a redundancy check with the merge candidateidentical to the first motion information candidate may be omitted in aredundancy check for the second motion information candidate.

FIG. 19 is a diagram showing an example in which a redundancy check witha specific merge candidate is omitted.

When a motion information candidate HmvpCand[i] whose index is i isadded to a merge candidate list, a redundancy check between the motioninformation candidate and pre-stored merge candidates in a mergecandidate list is performed. In this connection, when a merge candidatemergeCandlist[j] identical to a motion information candidate HmvpCand[i]is found, a redundancy check between a motion information candidateHmvpCand[i−1] whose index is i−1 and merge candidates may be performedwithout adding the motion information candidate HmvpCand[i] to a mergecandidate list. In this connection, a redundancy check between themotion information candidate HmvpCand[i−1] and the merge candidatemergeCandList[j] may be omitted.

In an example, in an example shown in FIG. 19, it was determined thatHmvpCand[i] and mergeCandList[2] are identical. Accordingly, aredundancy check for HmvpCand[i−1] may be performed without addingHmvpCand[i] to a merge candidate list. In this connection, a redundancycheck between HmvpCand[i−1] and mergeCandList[2] may be omitted.

When the number of a merge candidate included in the merge candidatelist of a current block is less than the threshold, at least one of apairwise merge candidate or a zero merge candidate may be additionallyincluded except for a motion information candidate. A pairwise mergecandidate means a merge candidate having a value obtained from averagingthe motion vectors of more than 2 merge candidates as a motion vectorand a zero merge candidate means a merge candidate whose motion vectoris 0.

For the merge candidate list of a current block, a merge candidate maybe added in the following order.

Spatial merge candidate—Temporal merge candidate—Motion informationcandidate—(Affine motion information candidate)—Pairwise mergecandidate—Zero merge candidate

A spatial merge candidate means a merge candidate derived from at leastone of a neighboring block or a non-neighboring block and a temporalmerge candidate means a merge candidate derived from a previousreference picture. An affine motion information candidate represents amotion information candidate derived from a block encoded/decoded by anaffine motion model.

A motion information table may be used in a motion vector predictionmode. In an example, when the number of a motion vector predictioncandidate included in the motion vector prediction candidate list of acurrent block is less than the threshold, a motion information candidateincluded in a motion information table may be set as a motion vectorprediction candidate for a current block. Concretely, the motion vectorof a motion information candidate may be set as a motion vectorprediction candidate.

If any one of motion vector prediction candidates included in the motionvector prediction candidate list of a current block is selected, aselected candidate may be set as a motion vector predictor of a currentblock. Then, after the motion vector residual value of a current blockis decoded, the motion vector of a current block may be obtained byadding up the motion vector predictor and the motion vector residualvalue.

The motion vector prediction candidate list of a current block may beconfigured in the following order.

Spatial motion vector prediction candidate—Temporal motion vectorprediction candidate—Motion information candidate—(Affine motioninformation candidate)—Zero motion vector prediction candidate

A spatial motion vector prediction candidate means a motion vectorprediction candidate derived from at least one of a neighboring block ora non-neighboring block and a temporal motion vector predictioncandidate means a motion vector prediction candidate derived from aprevious reference picture. An affine motion information candidaterepresents a motion information candidate derived from a blockencoded/decoded by an affine motion model. A zero motion vectorprediction candidate represents a candidate that the value of a motionvector is 0.

A merge processing region larger than a coding block may be defined.Coding blocks included in a merge processing region may be processed inparallel without being sequentially encoded/decoded. In this connection,not being sequentially encoded/decoded means the order ofencoding/decoding is not defined. Accordingly, the encoding/decodingprocess of blocks included in a merge processing region may beindependently processed. Alternatively, blocks included in a mergeprocessing region may share merge candidates. In this connection, themerge candidates may be derived based on a merge processing region.

According to the above-mentioned feature, a merge processing region maybe referred to as a parallel processing region, a shared merge region(SMR) or a merge estimation region (MER).

A merge candidate of a current block may be derived based on a codingblock. However, when a current block is included in a merge processingregion larger than the current block, a candidate block included in thesame merge processing region as the current block may be set to beunavailable as a merge candidate.

FIG. 20 is a diagram showing an example in which a candidate blockincluded in the same merge processing region as a current block is setto be unavailable as a merge candidate.

In an example shown in FIG. 20 (a), in the decoding/decoding of CU5,blocks including base samples adjacent to CU5 may be set as candidateblocks. In this connection, candidate blocks X3 and X4 included in thesame merge processing region as CU5 may be set to be unavailable as amerge candidate of CU5. But, candidate blocks X0, X1 and X2 not includedin the same merge processing region as CU5 may be set to be available asa merge candidate.

In an example shown in FIG. 20 (b), in the decoding/decoding of CU8,blocks including base samples adjacent to CU8 may be set as candidateblocks. In this connection, candidate blocks X6, X7 and X8 included inthe same merge processing region as CU8 may be set to be unavailable asa merge candidate. However, candidate blocks X5 and X9 not included inthe same merge processing region as CU8 may be set to be available as amerge candidate.

Alternatively, when a current block is included in a merge processingregion, a neighboring block adjacent to a current block and to a mergeprocessing region may be set as a candidate block.

FIG. 21 is a diagram showing an example which derives a merge candidatefor a current block when a current block is included in a mergeprocessing region.

As in an example shown in FIG. 21 (a), neighboring blocks adjacent to acurrent block may be set as candidate blocks for deriving the mergecandidate of the current block. In this connection, a candidate blockincluded in the same merge processing region as the current block may beset to be unavailable as a merge candidate. In an example, in deriving amerge candidate for a coding block CU3, a top neighboring block y3 and aright-top neighboring block y4 included in the same merge processingregion as the coding block CU3 may be set to be unavailable as a mergecandidate of the coding block CU3.

By scanning neighboring blocks adjacent to a current block in thepredefined order, a merge candidate may be derived. In an example, thepredefined order may be the order of y1, y3, y4, y0 and y2.

When the number of merge candidates which may be derived fromneighboring blocks adjacent to a current block is less than a value thatan offset is subtracted from the maximum number of merge candidates orthe maximum number, a merge candidate for the current block may bederived by using neighboring blocks adjacent to a merge processingregion like an example shown in FIG. 21 (b). In an example, neighboringblocks adjacent to a merge processing region including a coding blockCU3 may be set as candidate blocks for the coding block CU3. In thisconnection, neighboring blocks adjacent to a merge processing region mayinclude at least one of a left neighboring block x1, a top neighboringblock x3, a left-bottom neighboring block x0, a right-top neighboringblock x4 or a left-top neighboring block x2.

By scanning neighboring blocks adjacent to a merge processing region inthe predefined order, a merge candidate may be derived. In an example,the predefined order may be the order of x1, x3, x4, x0 and x2.

In summary, a merge candidate on the coding block CU3 including in amerge processing region may be derived by scanning candidate blocks inthe following scanning order.

(y1, y3, y4, y0, y2, x1, x3, x4, x0, x2)

But, the scanning order of the above-illustrated candidate blocks onlyshows the example of the present disclosure and candidate blocks may bescanned in the order different from the above example. Alternatively,the scanning order may be adaptively determined based on at least one ofa size or a shape of a current block or a merge processing region.

A merge processing region may be square or non-square. Information fordetermining a merge processing region may be signaled in a bitstream.The information may include at least one of information representing theshape of a merge processing region or information representing the sizeof a merge processing region. When a merge processing region isnon-square, at least one of information representing the size of a mergeprocessing region, information representing the width or height of amerge processing region or information representing a ratio between thewidth and height of a merge processing region may be signaled in abitstream.

The size of a merge processing region may be determined based on atleast one of information signaled in a bitstream, picture resolution,the size of a slice or the size of a tile.

If motion compensation prediction is performed for a block included in amerge processing region, a motion information candidate derived based onthe motion information of a block in which motion compensationprediction is performed may be added to a motion information table.

But, if a motion information candidate derived from a block included ina merge processing region is added to a motion information table, a casemay occur where a motion information candidate derived from the block isused in the encoding/decoding of other block in the merge processingregion whose encoding/decoding is actually slower than the block. Inother words, although dependence between blocks should be excluded inthe encoding/decoding of blocks included in a merge processing region, acase may occur where motion prediction compensation is performed byusing the motion information of other block included in the mergeprocessing region. To solve such a problem, although theencoding/decoding of a block included in a merge processing region iscompleted, the motion information of the block whose encoding/decodingis completed may not be added to a motion information table.

Alternatively, a motion information table may be updated by using only ablock at a predefined position in a merge processing region. Apredefined position may include at least one of a block at a top-leftposition, a block at a top-right position, a block at a bottom-leftposition, a block at a bottom-right position, a block at a centralposition, a block adjacent to the right boundary or a block adjacent tothe lower boundary in a merge processing region. In an example, only themotion information of a block adjacent to a bottom-right corner in amerge processing region may be updated in a motion information table andthe motion information of other blocks may not be updated in a motioninformation table.

Alternatively, after all blocks included in a merge processing regionare decoded, a motion information candidate derived from the blocks maybe added to a motion information table. In other words, while blocksincluded in a merge processing region are encoded/decoded, a motioninformation table may not be updated.

In an example, if motion compensation prediction is performed for blocksincluded in a merge processing region, a motion information candidatederived from the blocks may be added to a motion information table inthe predefined order. In this connection, the predefined order may bedetermined in the scanning order of coding blocks in a merge processingregion or a coding tree unit. The scanning order may be at least one ofraster scanning, horizontal scanning, vertical scanning or zigzagscanning. Alternatively, the predefined order may be determined based oneach block's motion information or the number of blocks with the samemotion information.

Alternatively, a motion information candidate including a unidirectionalmotion information may be added to motion information table before amotion information candidate including bidirectional motion information.On the contrary, motion information candidate including bidirectionalmotion information may be added to a motion information table before amotion information candidate including unidirectional motioninformation.

Alternatively, a motion information candidate may be added to a motioninformation table in the order of high frequency of use or low frequencyof use in a merge processing region or a coding tree unit.

When a current block is included in a merge processing region and thenumber of merge candidates included in a merge candidate list of thecurrent block is less than the maximum number, a motion informationcandidate included in a motion information table may be added to themerge candidate list. In this connection, a motion information candidatederived from a block included in the same merge processing region as acurrent block may be set not to be added to the merge candidate list ofthe current block.

Alternatively, when a current block is included in a merge processingregion, it may be set not to use a motion information candidate includedin a motion information table. In other words, although the number ofmerge candidates included in a merge candidate list of the current blockis less than the maximum number, a motion information candidate includedin a motion information table may not be added to the merge candidatelist.

In another example, a motion information table on a merge processingregion or a coding tree unit may be configured. This motion informationtable plays a role of temporarily storing the motion information ofblocks included in a merge processing region. To distinguish between ageneral motion information table and a motion information table for amerge processing region or a coding tree unit, the motion informationtable for the merge processing region or the coding tree unit isreferred to as a temporary motion information table. And, a motioninformation candidate stored in the temporary motion information tableis referred to as a temporary motion information candidate.

FIG. 22 is a diagram showing a temporary motion information table.

A temporary motion information table for a coding tree unit or a mergeprocessing region may be configured. When motion compensation predictionis performed for a current block included in a coding tree unit or amerge processing region, the motion information of the block may not beadded to a motion information table HmvpCandList. Instead, a temporarymotion information candidate derived from the block may be added to atemporary motion information table HmvpMERCandList. In other words, atemporary motion information candidate added to a temporary motioninformation table may not be added to a motion information table.Accordingly, a motion information table may not include a motioninformation candidate derived based on motion information of blocksincluded in a coding tree unit or a merge processing region including acurrent block.

Alternatively, only the motion information of some blocks among blocksincluded in a merge processing region may be added to a temporary motioninformation table. In an example, only blocks at a predefined positionin a merge processing region may be used to update a motion informationtable. A predefined position may include at least one of a block at atop-left position, a block at a top-right position, a block at abottom-left position, a block at a bottom-right position, a block at acentral position, a block adjacent to the right boundary or a blockadjacent to the lower boundary in a merge processing region. In anexample, only the motion information of a block adjacent to abottom-right corner in a merge processing region may be added to atemporary motion information table and the motion information of otherblocks may not be added to a temporary motion information table.

The maximum number of temporary motion information candidates which maybe included by a temporary motion information table may be set the sameas the maximum number of motion information candidates. Alternatively,the maximum number of temporary motion information candidates which maybe included by a temporary motion information table may be determinedaccording to a size of a coding tree unit or a merge processing region.Alternatively, the maximum number of temporary motion informationcandidates which may be included in a temporary motion information tablemay be set to be smaller than the maximum number of motion informationcandidates which may be included in a motion information table.

A current block included in a coding tree unit or a merge processingregion may be set not to use a temporary motion information table on thecorresponding coding tree unit or merge processing region. In otherwords, when the number of merge candidates included in the mergecandidate list of the current block is less than the threshold, a motioninformation candidate included in a motion information table may beadded to the merge candidate list and a temporary motion informationcandidate included in a temporary motion information table may not beadded to the merge candidate list. Accordingly, the motion informationof other block including in the same coding tree unit or the same mergeprocessing region as the current block may not be used for the motioncompensation prediction of the current block.

If the encoding/decoding of all blocks included in a coding tree unit ora merge processing region is completed, a motion information table and atemporary motion information table may be unified.

FIG. 23 is a diagram showing an example in which a motion informationtable and a temporary motion information table are unified.

If the encoding/decoding of all blocks included in a coding tree unit ora merge processing region is completed, a temporary motion informationcandidate included in a temporary motion information table may beupdated in a motion information table as in an example shown in FIG. 23.

In this connection, temporary motion information candidates included ina temporary motion information table may be added to a motioninformation table in the order inserted in the temporary motioninformation table. (In other words, in the ascending order or thedescending order of the index value)

In another example, temporary motion information candidates included ina temporary motion information table may be added to a motioninformation table in the predefined order. In this connection, thepredefined order may be determined in the scanning order of codingblocks in a merge processing region or a coding tree unit. The scanningorder may be at least one of raster scanning, horizontal scanning,vertical scanning or zigzag scanning. Alternatively, the predefinedorder may be determined based on the motion information of each block orthe number of blocks with the same motion information.

Alternatively, a temporary motion information candidate including aunidirectional motion information may be added to a motion informationtable before a temporary motion information candidate including abidirectional motion information. On the contrary, a temporary motioninformation candidate including a bidirectional motion information maybe added to a motion information table before a temporary motioninformation candidate including a unidirectional motion information.

Alternatively, a temporary motion information candidate may be added toa motion information table in the order of high frequency of use or lowfrequency of use in a merge processing region or a coding tree unit.

In case that a temporary motion information candidate included in atemporary motion information table is added to a motion informationtable, a redundancy check for a temporary motion information candidatemay be performed. In an example, when the same motion informationcandidate as a temporary motion information candidate included in atemporary motion information table is prestored in a motion informationtable, the temporary motion information candidate may not be added tothe motion information table. In this connection, a redundancy check maybe performed for a part of motion information candidates included in amotion information table. In an example, a redundancy check may beperformed for motion information candidates with an index over or belowthe threshold. In an example, when a temporary motion informationcandidate is equal to a motion information candidate with an index overthe predefined value, the temporary motion information candidate may notbe added to a motion information table.

It may limit the use of a motion information candidate derived from ablock included in the same coding tree unit or the same merge processingregion as a current block as the merge candidate of the current block.For it, the address information of a block may be additionally storedfor a motion information candidate. The address information of a blockmay include at least one of the position of the block, the address ofthe block, the index of the block, the position of a merge processingregion in which the block is included, the address of a merge processingregion in which the block is included, the index of a merge processingregion in which the block is included, the position of a coding treeregion in which the block is included, the address of a coding treeregion in which the block is included or the index of a coding treeregion in which the block is included.

A coding block may be partitioned into a plurality of prediction unitsand prediction may be performed for each of partitioned predictionunits. In this case, a prediction unit represents a base unit forperforming prediction.

A coding block may be partitioned by using at least one of a verticalline, a horizontal line, an oblique line or a diagonal line. Predictionunits partitioned by a partitioning line may have a shape such as atriangle, a quadrangle, a trapezoid or a pentagon. In an example, acoding block may be partitioned into two triangular prediction units,two trapezoidal prediction units, two quadrangular prediction units orone triangular prediction unit and one pentagonal prediction unit.

Information for determining at least one of the number, an angle or aposition of a line partitioning a coding block may be signaled in abitstream. In an example, information representing one of partition typecandidates of a coding block may be signaled in a bitstream orinformation specifying one of a plurality of line candidatespartitioning a coding block may be signaled in a bitstream. In anexample, index information indicating one of a plurality of linecandidates may be signaled in a bitstream.

For each of a plurality of line candidates, at least one of an angle ora position may be different. The number of line candidates which isavailable for a current block may be determined based on a size or ashape of a current block, the number of available merge candidates orwhether a neighboring block at a specific position is available as amerge candidate.

Alternatively, information for determining the number or a type of linecandidates may be signaled in a bitstream. In an example, whether anoblique line with an angle greater than a diagonal line and/or anoblique line with an angle smaller than a diagonal line is available asa line candidate may be determined by using a 1-bit flag. Theinformation may be signaled at a sequence, a picture or a sequencelevel.

Alternatively, based on at least one of an intra prediction mode or aninter prediction mode of a coding block, a position of an availablemerge candidate or a partitioning type of a neighboring block, at leastone of the number, an angle or a position of a line partitioning acoding block may be adaptively determined.

When a coding block is partitioned into a plurality of prediction units,intra prediction or inter prediction may be performed for eachpartitioned prediction unit.

FIG. 24 is a diagram showing an example in which a coding block ispartitioned into a plurality of prediction units by using a diagonalline.

As in an example shown in FIGS. 24 (a) and (b), a coding block may bepartitioned into two triangular prediction units by using a diagonalline.

FIGS. 24 (a) and (b) showed that a coding block is partitioned into twoprediction units by using a diagonal line connecting two vertexes of acoding block. But, a coding block may be partitioned into two predictionunits by using an oblique line that at least one end of a line does notpass a vertex of a coding block.

FIG. 25 is a diagram showing an example in which a coding block ispartitioned into two prediction units.

As in an example shown in FIGS. 25 (a) and (b), a coding block may bepartitioned into two prediction units by using an oblique line that bothends adjoin the upper and lower boundary of a coding block,respectively.

Alternatively, as in an example shown in FIGS. 25 (c) and (d), a codingblock may be partitioned into two prediction units by using an obliqueline that both ends adjoin the left and right boundary of a codingblock, respectively.

Alternatively, a coding block may be partitioned into two predictionunits with a different size. In an example, a coding block may bepartitioned into two prediction units with a different size by settingan oblique line partitioning a coding block to meet two boundariesforming one vertex.

FIG. 26 shows examples in which a coding block is partitioned into aplurality of different-sized prediction blocks.

As in an example shown in FIGS. 26 (a) and (b), a coding block may bepartitioned into two prediction units with a different size by setting adiagonal line connecting the top-left and bottom-right of a coding blockto pass the left boundary, the right boundary, the upper boundary or thelower boundary instead of a top-left corner or a bottom-right corner ofa coding block.

Alternatively, as in an example shown in FIGS. 26 (c) and (d), a codingblock may be partitioned into two prediction units with a different sizeby setting a diagonal line connecting the top-right and the bottom-leftof a coding block to pass the left boundary, the right boundary, theupper boundary or the lower boundary instead of a top-left corner or abottom-right corner of a coding block.

Each of prediction units generated by partitioning a coding block isreferred to as ‘the N-th prediction unit’. In an example, in an exampleshown in FIG. 24 to FIG. 26, PU1 may be defined as the first predictionunit and PU2 may be defined as the second prediction unit. The firstprediction unit may mean a prediction unit which includes a sample at abottom-left position or a sample at a top-left position in a codingblock and the second prediction unit may mean a prediction unit whichincludes a sample at a top-right position or a sample at a bottom-rightposition in a coding block.

Conversely, a prediction unit which includes a sample at a top-rightposition or a sample at a bottom-right position in a coding block may bedefined as the first prediction unit and a prediction unit whichincludes a sample at a bottom-left position or a sample at a top-leftposition in a coding block may be defined as the second prediction unit.

When a coding block is partitioned by using a horizontal line, avertical line, a diagonal line or an oblique line, it may be referred toas prediction unit partitioning. A prediction unit generated by applyingthe prediction unit partitioning may be referred to as a triangularprediction unit, a quadrangular prediction unit or a pentagonalprediction unit according to its shape.

In the embodiments in below, it will be assumed that a coding block ispartitioned by using a diagonal line. In particular, when a coding blockis partitioned into two prediction units by using a diagonal line, it isreferred to as diagonal partitioning or triangular partitioning. But,even when a coding block is partitioned by using an oblique line with anangle different from a vertical line, a horizontal line or a diagonalline, prediction units may be encoded/decoded according to thebelow-described embodiments. In other words, matters related to theencoding/decoding of the below-described triangular prediction unit maybe also applied to the encoding/decoding of a quadrangular predictionunit or a pentagonal prediction unit.

Whether prediction unit partitioning will be applied to a coding blockmay be determined based on at least one of a slice type, the maximumnumber of merge candidates which may be included in a merge candidatelist, a size of a coding block, a shape of a coding block, a predictionencoding mode of a coding block or a partitioning aspect of a parentnode.

In an example, whether prediction unit partitioning will be applied to acoding block may be determined based on whether a current slice is a Btype. Prediction unit partitioning may be allowed only when a currentslice is a B type.

Alternatively, whether prediction unit partitioning will be applied to acoding block may be determined based on whether the maximum number ofmerge candidates included in a merge candidate list is equal to orgreater than 2. Prediction unit partitioning may be allowed only whenthe maximum number of merge candidates included in a merge candidatelist is equal to or greater than 2.

Alternatively, when at least one of a width or a height is greater than64, a disadvantage may be occurred during implementation of a hardwarethat a 64×64-sized data processing unit is redundantly accessed.Accordingly, when at least one of a width or a height of a coding blockis greater than a threshold value, it may not be allowed to partition acoding block into a plurality of prediction units. In an example, whenat least one of a width or a height of a coding block is greater than 64(e.g., when at least one of a width or a height is 128), prediction unitpartitioning may not be used.

Alternatively, by considering the maximum number of samples which may besimultaneously processed by implemented hardware, prediction unitpartitioning may not be allowed for a coding block that the number ofsamples is greater than a threshold value. In an example, predictionunit partitioning may not be allowed for a coding tree block that thenumber of samples is greater than 4096.

Alternatively, prediction unit partitioning may not be allowed for acoding block that the number of samples included in a coding block issmaller than a threshold value. In an example, when the number ofsamples included in a coding block is smaller than 64, prediction unitpartitioning may be set not to be applied to a coding block.

Alternatively, whether prediction unit partitioning will be applied to acoding block may be determined based on at least one of whether a widthand height ratio of a coding block is smaller than the first thresholdvalue or whether a width and height ratio of a coding block is greaterthan the second threshold value. In this case, a width and height ratioof a coding block, whRatio, may be determined as a ratio of a width CbWand a height CbH of a coding block as in the following Equation 2.whRatio=abs(Log₂(CbW/CbH))  [Equation 2]

Alternatively, when a width and height ratio of a coding block issmaller than the first threshold value or greater than the secondthreshold value, prediction unit partitioning may be applied to a codingblock. In an example, when the first threshold value is 4, predictionunit partitioning may not be allowed for a 64×4 or 4×64-sized codingblock.

Alternatively, based on a partitioning type of a parent node, whetherprediction unit partitioning is allowed may be determined. In anexample, when a coding block, a parent node, is partitioned based onquad tree partitioning, prediction unit partitioning may be applied to acoding block, a leaf node. On the other hand, when a coding block, aparent node, is partitioned based on binary tree or triple treepartitioning, prediction unit partitioning may be set to be unallowablefor a coding block, a leaf node.

Alternatively, based on a prediction encoding mode of a coding block,whether prediction unit partitioning is allowed may be determined. In anexample, prediction unit partitioning may be allowed only when a codingblock is encoded by intra prediction, when a coding block is encoded byinter prediction or when a coding block is encoded by a predefined interprediction mode. In this case, a predefined inter prediction mode mayinclude at least one of a merge mode, a motion vector prediction mode,an affine merge mode or an affine motion vector prediction mode.

Alternatively, based on a size of a parallel processing region, whetherprediction unit partitioning is allowed may be determined. In anexample, when a size of a coding block is greater than that of aparallel processing region, prediction unit partitioning may not beused.

By considering two or more of the above-enumerated conditions, whetherprediction unit partitioning will be applied to a coding block may bedetermined.

In another example, information representing whether prediction unitpartitioning will be applied to a coding block may be signaled in abitstream. The information may be signaled at a sequence, a picture, aslice or a block level. For example, a flag, triangle_partition_flag,representing whether prediction unit partitioning is applied to a codingblock, may be signaled at a coding block level.

When it is determined to apply prediction unit partitioning to a codingblock, information representing the number of lines partitioning acoding block or a position of a line may be signaled in a bitstream.

In an example, when a coding block is partitioned by a diagonal line,information representing a direction of a diagonal line partitioning acoding block may be signaled in a bitstream. In an example, a flag,triangle_partition_type_flag, representing a direction of a diagonalline, may be signaled in a bitstream. The flag represents whether acoding block is partitioned by a diagonal line connecting a top-left anda bottom-right or whether a coding block is partitioned by a diagonalline connecting a top-right and a bottom-left. When a coding block ispartitioned by a diagonal line connecting a top-left and a bottom-right,it may be referred to as a left triangular partition type and when acoding block is partitioned by a diagonal line connecting a top-rightand a bottom-left, it may be referred to as a right triangular partitiontype. In an example, when a value of the flag is 0, it may representthat a partition type of a coding block is a left triangular partitiontype and when a value of the flag is 1, it may represent that apartition type of a coding block is a right triangular partition type.

In addition, information representing whether sizes of prediction unitsare the same or information representing a position of a diagonal linepartitioning a coding block may be signaled in a bitstream. In anexample, when information representing sizes of prediction unitsrepresents that sizes of prediction units are the same, the encoding ofinformation representing a position of a diagonal line may be omittedand a coding block may be partitioned into two prediction units by usinga diagonal line which passes two vertexes of a coding block. On theother hand, when information representing sizes of prediction unitsrepresents that sizes of prediction units are not the same, a positionof a diagonal line partitioning a coding block may be determined basedon information representing a position of a diagonal line. In anexample, when a left triangular partition type is applied to a codingblock, the position information may represent whether a diagonal linemeets the left boundary and the lower boundary of a coding block orwhether a diagonal line meets the upper boundary and the right boundary.Alternatively, when a right triangular partition type is applied to acoding block, the position information may represent whether a diagonalline meets the right boundary and the lower boundary of a coding blockor whether a diagonal line meets the upper boundary and the leftboundary.

Information representing a partition type of a coding block may besignaled at a coding block level. Accordingly, a partition type may bedetermined per coding block to which prediction unit partitioning isapplied.

In another example, information representing a partition type for asequence, a picture, a slice, a tile or a coding tree unit may besignaled. In this case, partition types of coding blocks to whichdiagonal partitioning is applied in a sequence, a picture, a slice, atile or a coding tree unit may be set the same.

Alternatively, information for determining a partition type for thefirst coding unit to which prediction unit partitioning is applied in acoding tree unit may be encoded and signaled, and coding units to whichprediction unit partitioning is applied for the second or later may beset to use the same partition type as the first coding unit.

In another example, a partition type of a coding block may be determinedbased on a partition type of a neighboring block. In this case, aneighboring block may include at least one of a neighboring blockadjacent to the top-left corner of a coding block, a neighboring blockadjacent to the top-right corner, a neighboring block adjacent to thebottom-left corner, a neighboring block positioned at the top or aneighboring block positioned at the left. In an example, a partitiontype of a current block may be set the same as a partition type of aneighboring block. Alternatively, a partition type of a current blockmay be determined based on whether a left triangular partition type isapplied to a top-left neighboring block or whether a right triangularpartition type is applied to a top-right neighboring block or abottom-left neighboring block.

To perform motion prediction compensation for the first prediction unitand the second prediction unit, the motion information of each of thefirst prediction unit and the second prediction unit may be derived. Inthis case, the motion information of the first prediction unit and thesecond prediction unit may be derived from merge candidates included ina merge candidate list. To distinguish between a general merge candidatelist and a merge candidate list used to derive the motion information ofprediction units, a merge candidate list for deriving the motioninformation of prediction units is referred to as a partitioning modemerge candidate list or a triangular merge candidate list. In addition,a merge candidate included in a partitioning mode merge candidate listis referred to as a partitioning mode merge candidate or a triangularmerge candidate. But, applying the above-described method of deriving amerge candidate and the above-described method of constituting a mergecandidate list to derive a partitioning mode merge candidate and toconstitute a partitioning mode merge candidate list is also included ina scope of the preset disclosure.

Information for determining the maximum number of partitioning modemerge candidates which may be included in a partitioning mode mergecandidate list may be signaled in a bitstream. The information mayrepresent a difference between the maximum number of merge candidateswhich may be included in a merge candidate list and the maximum numberof partitioning mode merge candidates which may be included in apartitioning mode merge candidate list.

A partitioning mode merge candidate may be derived from a spatialneighboring block and a temporal neighboring block of a coding block.

FIG. 27 is a diagram showing neighboring blocks used to derive apartitioning mode merge candidate.

A partitioning mode merge candidate may be derived by using at least oneof a neighboring block positioned at the top of a coding block, aneighboring block positioned at the left of a coding block or acollocated block included in a picture different from a coding block. Atop neighboring block may include at least one of a block including asample (xCb+CbW−1, yCb−1) positioned at the top of a coding block, ablock including a sample (xCb+CbW, yCb−1) positioned at the top of acoding block or a block including a sample (xCb−1, yCb−1) positioned atthe top of a coding block. A left neighboring block may include at leastone of a block including a sample (xCb−1, yCb+CbH−1) positioned at theleft of a coding block or a block including a sample (xCb−1, yCb+CbH)positioned at the left of a coding block. A collocated block may bedetermined as one of a block including a sample (xCb+CbW, yCb+CbH)adjacent to the top-right corner of a coding block or a block includinga sample (xCb/2, yCb/2) positioned at the center of a coding block in acollocated picture.

Neighboring blocks may be searched in a predefined order, and apartitioning mode merge candidate list may be configured withpartitioning mode merge candidates according to the predefined order. Inan example, a partitioning mode merge candidate may be searched in theorder of B1, A1, B0, A0, C0, B2 and C1 to configure a partitioning modemerge candidate list.

The motion information of prediction units may be derived based on thepartitioning mode merge candidate list. In other words, prediction unitsmay share a single partitioning mode merge candidate list.

To derive the motion information of a prediction unit, information forspecifying at least one of partitioning mode merge candidates includedin a partitioning mode merge candidate list may be signaled in abitstream. In an example, index information, merge_triangle_idx, forspecifying at least one of partitioning mode merge candidates may besignaled in a bitstream.

Index information may specify a combination of a merge candidate of thefirst prediction unit and a merge candidate of the second predictionunit. In an example, the following table 1 is an example representing acombination of merge candidates according to index information,merge_triangle_idx.

TABLE 1 merge_triangle_idx 0 1 2 3 4 5 6 7 8 First Prediction 1 0 0 0 20 0 1 3 Unit Second Prediction 0 1 2 1 0 3 4 0 0 Unit merge_triangle_idx9 10 11 12 13 14 15 16 17 First Prediction 4 0 1 1 0 0 1 1 1 Unit SecondPrediction 0 2 2 2 4 3 3 4 4 Unit merge_triangle_idx 18 19 20 21 22 2324 25 26 First Prediction 1 2 2 2 4 3 3 3 4 Unit Second Prediction 3 1 01 3 0 2 4 0 Unit merge_triangle_idx 27 28 29 30 31 32 33 34 35 FirstPrediction 3 2 4 4 2 4 3 4 3 Unit Second Prediction 1 3 1 1 3 2 2 3 1Unit merge_triangle_idx 36 37 38 39 First Prediction 2 2 4 3 Unit SecondPrediction 4 4 2 4 Unit

When a value of index information, merge_triangle_idx, is 1, itrepresents that the motion information of the first prediction unit isderived from a merge candidate whose index is 1 and the motioninformation of the second prediction unit is derived from a mergecandidate whose index is 0. A partitioning mode merge candidate forderiving the motion information of the first prediction unit and apartitioning mode merge candidate for deriving the motion information ofthe second prediction unit may be determined by index information,merge_triangle_idx. It is also possible to determine based on the indexinformation a partition type of a coding block to which diagonalpartitioning is applied. In other words, index information may specify acombination of a merge candidate of the first prediction unit, a mergecandidate of the second prediction unit and a partitioning direction ofa coding block. When a partition type of a coding block is determined byindex information, information, triangle_partition_type_flag,representing a direction of a diagonal line partitioning a coding blockmay not be encoded. Table 2 represents a partition type of a codingblock for index information, merge_triangle_idx.

TABLE 2 merge_triangle_idx 0 1 2 3 4 5 6 7 8 TriangleDir 0 1 1 0 0 1 1 10 merge_triangle_idx 9 10 11 12 13 14 15 16 17 TriangleDir 0 0 0 1 0 0 00 1 merge_triangle_idx 18 19 20 21 22 23 24 25 26 TriangleDir 1 1 1 0 01 1 1 1 merge_triangle_idx 27 28 29 30 31 32 33 34 35 TriangleDir 1 1 10 0 1 0 1 0 merge_triangle_idx 36 37 38 39 TriangleDir 0 1 0 0

When a variable, TriangleDir, is 0, it represents that a left triangularpartition type is applied to a coding block and when a variable,TriangleDir, is 1, it represents that a right triangular partition typeis applied to a coding block. By combining Table 1 and Table 2, indexinformation, merge_triangle_idx, may be set to specify a combination ofa merge candidate of the first prediction unit, a merge candidate of thesecond prediction unit and a partitioning direction of a coding block.In another example, index information only for one of the firstprediction unit and the second prediction unit may be signaled and anindex of a merge candidate for the other of the first prediction unitand the second prediction unit may be determined based on the indexinformation. In an example, a merge candidate of the first predictionunit may be determined based on index information, merge_triangle_idx,representing an index of one of partitioning mode merge candidates. And,a merge candidate of the second prediction unit may be specified basedon the merge_triangle_idx. In an example, a merge candidate of thesecond prediction unit may be derived by adding or subtracting an offsetto or from the index information, merge_triangle_idx. An offset may bean integer such as 1 or 2. In an example, a merge candidate of thesecond prediction unit may be determined as a partitioning mode mergecandidate having a value obtained by adding 1 to merge_triangle_idx asan index. When merge_triangle_idx indicates a partitioning mode mergecandidate with the largest index value among partitioning mode mergecandidates, the motion information of the second prediction unit may bederived from a partitioning mode merge candidate whose index is 0 or apartitioning mode merge candidate having a value subtracting 1 frommerge_triangle_idx as an index.

Alternatively, the motion information of the second prediction unit maybe derived from a partitioning mode merge candidate with the samereference picture as a partitioning mode merge candidate of the firstprediction unit specified by index information. In this case, apartitioning mode merge candidate with the same reference picture as apartitioning mode merge candidate of the first prediction unit mayrepresent a partitioning mode merge candidate that at least one of a L0reference picture or a L1 reference picture is the same as apartitioning mode merge candidate of the first prediction unit. Whenthere are a plurality of partitioning mode merge candidates with thesame reference picture as a partitioning mode merge candidate of thefirst prediction unit, any one may be selected based on at least one ofwhether a merge candidate includes bi-directional motion information ora difference value between an index of a merge candidate and indexinformation.

In another example, index information may be signaled for each of thefirst prediction unit and the second prediction unit. In an example, thefirst index information, 1st_merge_idx, for determining a partitioningmode merge candidate of the first prediction unit, and the second indexinformation, 2nd_merge_idx, for determining a partitioning mode mergecandidate of the second prediction unit, may be signaled in a bitstream.The motion information of the first prediction unit may be derived froma partitioning mode merge candidate determined based on the first indexinformation, 1st_merge_idx, and the motion information of the secondprediction unit may be derived from a partitioning mode merge candidatedetermined based on the second index information, 2nd_merge_idx.

The first index information, 1st_merge_idx, may represent an index ofone of partitioning mode merge candidates included in a partitioningmode merge candidate list. A partitioning mode merge candidate of thefirst prediction unit may be determined as a partitioning mode mergecandidate indicated by the first index information, 1st_merge_idx.

A partitioning mode merge candidate indicated by the first indexinformation, 1st_merge_idx, may be set to be unavailable as apartitioning mode merge candidate of the second prediction unit.Accordingly, the second index information of the second prediction unit,2nd_merge_idx, may represent an index of any one of remainingpartitioning mode merge candidates except for a partitioning mode mergecandidate indicated by the first index information. When a value of thesecond index information, 2nd_merge_idx, is smaller than that of thefirst index information, 1st_merge_idx, a partitioning mode mergecandidate of the second prediction unit may be determined as apartitioning mode merge candidate having index information representedby the second index information, 2nd_merge_idx. On the other hand, whena value of the second index information, 2nd_merge_idx, is the same asor greater than that of the first index information, 1st_merge_idx, apartitioning mode merge candidate of the second prediction unit may bedetermined as a partitioning mode merge candidate having a valueobtained by adding 1 to a value of the second index information,2nd_merge_idx, as an index.

Alternatively, according to the number of partitioning mode mergecandidates included in a partitioning mode merge candidate list, whetherthe second index information is signaled or not may be determined. In anexample, when the maximum number of partitioning mode merge candidateswhich may be included in a partitioning mode merge candidate list doesnot exceed 2, the signaling of the second index information may beomitted. When the signaling of the second index information is omitted,the second partitioning mode merge candidate may be derived by adding orsubtracting an offset to or from the first index information. In anexample, when the maximum number of partitioning mode merge candidateswhich may be included in a partitioning mode merge candidate list is 2and the first index information indicates an index of 0, the secondpartitioning mode merge candidate may be derived by adding 1 to thefirst index information. Alternatively, when the maximum number ofpartitioning mode merge candidates which may be included in apartitioning mode merge candidate list is 2 and the first indexinformation indicates 1, the second partitioning mode merge candidatemay be derived by subtracting 1 from the first index information.

Alternatively, when the signaling of the second index information isomitted, the second index information may be inferred as a defaultvalue. In this case, a default value may be 0. The second partitioningmode merge candidate may be derived by comparing the first indexinformation with the second index information. In an example, when thesecond index information is smaller than the first index information, amerge candidate whose index is 0 may be set as the second partitioningmode merge candidate and when the second index information is the sameas or greater than the first index information, a merge candidate whoseindex is 1 may be set as the second partitioning mode merge candidate.

When a partitioning mode merge candidate has unidirectional motioninformation, the unidirectional motion information of a partitioningmode merge candidate may be set as the motion information of aprediction unit. On the other hand, when a partitioning mode mergecandidate has bidirectional motion information, only one of L0 motioninformation or L1 motion information may be set as the motioninformation of a prediction unit. Which of L0 motion information or L1motion information will be taken may be determined based on an index ofa partitioning mode merge candidate or the motion information of theother prediction unit.

In an example, when an index of a partitioning mode merge candidate isan even number, the L0 motion information of a prediction unit may beset to be 0 and the L1 motion information of a partitioning mode mergecandidate may be set as the L1 motion information of a prediction unit.On the other hand, when an index of a partitioning mode merge candidateis an odd number, the L1 motion information of a prediction unit may beset to be 0 and the L0 motion information of a partitioning mode mergecandidate may be set to be 0. Conversely, when an index of apartitioning mode merge candidate is an even number, the L0 motioninformation of a partitioning mode merge candidate may be set as the L0motion information of a prediction unit and when an index of apartitioning mode merge candidate is an odd number, the L1 motioninformation of a partitioning mode merge candidate may be set as the L1motion information of a prediction unit. Alternatively, for a firstprediction unit, the L0 motion information of a partitioning mode mergecandidate may be set as the L0 motion information of the firstprediction unit when a partitioning mode merge candidate for the firstprediction unit is an even number, but, for a second prediction unit,the L1 motion information of a partitioning mode merge candidate may beset as the L1 motion information of the second prediction unit when apartitioning mode merge candidate for the second prediction unit is anodd number.

Alternatively, when the first prediction unit has L0 motion information,the L0 motion information of the second prediction unit may be set to be0 and the L1 motion information of a partitioning mode merge candidatemay be set as the L1 information of the second prediction unit. On theother hand, when the first prediction unit has L1 motion information,the L1 motion information of the second prediction unit may be set to be0 and the L0 motion information of a partitioning mode merge candidatemay be set as the L0 motion information of the second prediction unit.

A partitioning mode merge candidate list for deriving the motioninformation of the first prediction unit may be set to be different froma partitioning mode merge candidate list for deriving the motioninformation of the second prediction unit.

In an example, when a partitioning mode merge candidate for deriving themotion information of the first prediction unit in a partitioning modemerge candidate list is specified based on index information for thefirst prediction unit, the motion information of the second predictionunit may be derived by using a partitioning mode merge list includingremaining partitioning mode merge candidates except for the partitioningmode merge candidate indicated by the index information. Concretely, themotion information of the second prediction unit may be derived from oneof remaining partitioning mode merge candidates.

Accordingly, the maximum number of partitioning mode merge candidatesincluded in a partitioning mode merge candidate list of the firstprediction unit may be different from the maximum number of partitioningmode merge candidates included in a partitioning mode merge candidatelist of the second prediction unit. In an example, when a partitioningmode merge candidate list of the first prediction unit includes M mergecandidates, a partitioning mode merge candidate list of the secondprediction unit may include M−1 merge candidates except for thepartitioning mode merge candidate indicated by the index information ofthe first prediction unit.

In another example, the availability of a neighboring block may bedetermined by deriving a merge candidate of each prediction unit basedon neighboring blocks adjacent to a coding block, but by considering ashape or a position of a prediction unit.

FIG. 28 is a diagram for explaining an example in which the availabilityof a neighboring block is determined per prediction unit.

A neighboring block which is not adjacent to the first prediction unitmay be set to be unavailable for the first prediction unit and aneighboring block which is not adjacent to the second prediction unitmay be set to be unavailable for the second prediction unit.

In an example, as in an example shown in FIG. 28 (a), when a lefttriangular partition type is applied to a coding block, blocks A1, A0and A2 adjacent to the first prediction unit among neighboring blocksadjacent to a coding block may be determined to be available for thefirst prediction unit, but blocks B0 and B1 may be determined to beunavailable for the first prediction unit. Accordingly, a partitioningmode merge candidate list for the first prediction unit may includepartitioning mode merge candidates derived from blocks A1, A0 and A2,but it may not include partitioning mode merge candidates derived fromblocks B0 and B1.

As in an example shown in FIG. 28 (b), when a left triangular partitiontype is applied to a coding block, blocks B0 and B1 adjacent to thesecond prediction unit may be determined to be available for the secondprediction unit, but blocks A1, A0 and A2 may be determined to beunavailable for the second prediction unit. Accordingly, a partitioningmode merge candidate list for the second prediction unit may includepartitioning mode merge candidates derived from blocks B0 and B1, but itmay not include partitioning mode merge candidates derived from blocksA1, A0 and A2.

Accordingly, the number of partitioning mode merge candidates which maybe used by a prediction unit or a range of partitioning mode mergecandidates may be determined based on at least one of a position of aprediction unit or a partition type of a coding block.

In another example, a merge mode may be applied to only one of the firstprediction unit and the second prediction unit. And, the motioninformation of the other of the first prediction unit and the secondprediction unit may be set the same as the motion information of aprediction unit to which the merge mode is applied or may be derived byrefining the motion information of a prediction unit to which the mergemode is applied.

In an example, a motion vector and a reference picture index of thefirst prediction unit may be derived based on a partitioning mode mergecandidate, and a motion vector of the second prediction unit may bederived by refining a motion vector of the first prediction unit. In anexample, a motion vector of the second prediction unit may be derived byadding or subtracting a refine motion vector {Rx, Ry} to or from amotion vector of the first prediction unit, {mvD1LXx, mvD1LXy}. Areference picture index of the second prediction unit may be set thesame as a reference picture index of the first prediction unit.

Information for determining a refine motion vector representing adifference between a motion vector of the first prediction unit and amotion vector of the second prediction unit may be signaled in abitstream. The information may include at least one of informationrepresenting a size of a refine motion vector or informationrepresenting a sign of a refine motion vector.

Alternatively, a sign of a refine motion vector may be derived based onat least one of a position or an index of a prediction unit or apartition type which is applied to a coding block.

In another example, a motion vector and a reference picture index of oneof the first prediction unit and the second prediction unit may besignaled. A motion vector of the other of the first prediction unit andthe second prediction unit may be derived by refining the signaledmotion vector.

In an example, based on information signaled in a bitstream, a motionvector and a reference picture index of the first prediction unit may bedetermined. And, a motion vector of the second prediction unit may bederived by refining a motion vector of the first prediction unit. In anexample, a motion vector of the second prediction unit may be derived byadding or subtracting a refine motion vector {Rx, Ry} to or from amotion vector of the first prediction unit, {mvD1LXx, mvD1LXy}. Areference picture index of the second prediction unit may be set thesame as a reference picture index of the first prediction unit.

In another example, a merge mode may be applied to only one of the firstprediction unit and the second prediction unit. And, the motioninformation of the other of the first prediction unit and the secondprediction unit may be derived based on the motion information of aprediction unit to which the merge mode is applied. In an example, asymmetric motion vector of a motion vector of the first prediction unitmay be set as a motion vector of the second prediction unit. In thiscase, a symmetric motion vector may mean a motion vector which has thesame magnitude as a motion vector of the first prediction unit, but hasat least one opposite sign of an x-axis or a y-axis component, or amotion vector which has the same magnitude as a scaled vector obtainedby scaling a motion vector of the first prediction unit, but has atleast one opposite sign of an x-axis or a y-axis component. In anexample, when a motion vector of the first prediction unit is (MVx,MVy), a motion vector of the second prediction unit may be set to be(MVx, −MVy), (−MVx, MVy) or (−MVx, −MVy) which is a symmetric motionvector of the motion vector.

A reference picture index of a prediction unit to which a merge mode isnot applied among the first prediction unit and the second predictionunit may be set the same as a reference picture index of a predictionunit to which a merge mode is applied. Alternatively, a referencepicture index of a prediction unit to which a merge mode is not appliedmay be set as a predefined value. In this case, a predefined value maybe the smallest index or the largest index in a reference picture list.Alternatively, information specifying a reference picture index of aprediction unit to which a merge mode is not applied may be signaled ina bitstream. Alternatively, a reference picture of a prediction unit towhich a merge mode is not applied may be selected from a referencepicture list different from a reference picture list to which areference picture of a prediction unit to which a merge mode is appliedbelongs. In an example, when a reference picture of a prediction unit towhich a merge mode is applied is selected from an L0 reference picturelist, a reference picture of a prediction unit to which a merge mode isnot applied may be selected from an L1 reference picture list. In thiscase, a reference picture of a prediction unit to which a merge mode isnot applied may be derived based on a picture order count (POC)difference between a reference picture of a prediction unit to which amerge mode is applied and a current picture. In an example, when areference picture of a prediction unit to which a merge mode is appliedis selected from a L0 reference picture list, a reference picture that adifference value with a current picture in a L1 reference picture listis the same as or similar to a difference value between a referencepicture of a prediction unit to which a merge mode is applied and acurrent picture may be selected as a reference picture of a predictionunit to which a merge mode is not applied.

When a picture order count difference value between a reference pictureof the first prediction unit and a current picture is different from apicture order count difference value between a reference picture of thesecond prediction unit and a current picture, a symmetric motion vectorof a scaled motion vector of a prediction unit to which a merge mode isapplied may be set as a motion vector of a prediction unit to which amerge mode is not applied. In this case, scaling may be performed basedon a picture order count difference value between each reference pictureand a current picture.

In another example, after deriving a motion vector of each of the firstprediction unit and the second prediction unit, a refine vector may beadded to or subtracted from a derived motion vector. In an example, amotion vector of the first prediction unit may be derived by adding orsubtracting the first refine vector to or from the first motion vectorderived based on the first merge candidate and a motion vector of thesecond prediction unit may be derived by adding or subtracting thesecond refine vector to or from the second motion vector derived basedon the second merge candidate. Information for determining at least oneof the first refine vector or the second refine vector may be signaledin a bitstream. The information may include at least one of informationfor determining a magnitude of a refine vector or information fordetermining a sign of a refine vector.

The second refine vector may be a symmetric motion vector of the firstrefine vector. In this case, information for determining a refine vectormay be signaled only for one of the first refine vector and the secondrefine vector. In an example, when the first refine vector is determinedto be (MVDx, MVDy) by information signaled in a bitstream, (−MVDx,MVDy), (MVDx, −MVDy) or (−MVDx, −MVDy) which is a symmetric motionvector of the first refine vector may be set as the second refinevector. According to the picture order count of a reference picture ofeach prediction unit, a symmetric motion vector of a scaled motionvector obtained by scaling the first refine vector may be set as thesecond refine vector.

In another example, information of one of the first prediction unit andthe second prediction unit may be derived based on a merge candidate andthe motion information of the other may be determined based oninformation signaled in a bitstream. In an example, a merge index may besignaled for the first prediction unit and at least one of informationfor determining a motion vector and information for determining areference picture may be signaled for the second prediction unit. Themotion information of the first prediction unit may be set the same asthe motion information of a merge candidate specified by a merge index.The motion information of the second prediction unit may be specified byat least one of information for determining a motion vector signaled ina bitstream and information for determining a reference picture.

A motion prediction compensation prediction for each coding block may beperformed based on the motion information of the first prediction unitand the motion information of the second prediction unit. In this case,quality degradation may be generated on the boundary of the firstprediction unit and the second prediction unit. In an example, qualitycontinuity may deteriorate around an edge on the boundary of the firstprediction unit and the second prediction unit. To reduce qualitydegradation on the boundary, a prediction sample may be derived by asmoothing filter or a weighted prediction.

A prediction sample in a coding block to which diagonal partitioning isapplied may be derived based on a weighted sum operation of the firstprediction sample obtained based on the motion information of the firstprediction unit and the second prediction sample obtained based on themotion information of the second prediction unit. Alternatively, aprediction sample of the first prediction unit may be derived from thefirst prediction block determined based on the motion information of thefirst prediction unit and a prediction sample of the second predictionunit may be derived from the second prediction block determined based onthe motion information of the second prediction unit, but a predictionsample on the boundary region of the first prediction unit and thesecond prediction unit may be derived based on a weighted sum operationof the first prediction sample included in the first prediction blockand the second prediction sample included in the second predictionblock. In an example, the following Equation 3 represents an example ofderiving a prediction sample of the first prediction unit and the secondprediction unit.P(x,y)=w1*P1(x,y)±(1−w1)*P2(x,y)  [Equation 3]

In the Equation 3, P1 represents the first prediction sample and P2represents the second prediction sample. w1 represents a weight which isapplied to the first prediction sample and (1−w1) represents a weightwhich is applied to the second prediction sample. As in an example shownin Equation 3, a weight which is applied to the second prediction samplemay be derived by subtracting a weight which is applied to the firstprediction sample from a constant value.

When a left triangular partition type is applied to a coding block, aboundary region may include prediction samples with the same x-axiscoordinate and y-axis coordinate. On the other hand, when a righttriangular partition type is applied to a coding block, a boundaryregion may include prediction samples that a sum of an x-axis coordinateand a y-axis coordinate is equal to or greater than the first thresholdvalue and is equal to or less than the second threshold value.

A size of a boundary region may be determined based on at least one of asize of a coding block, a shape of a coding block, the motioninformation of prediction units, a motion vector difference value ofprediction units, a picture order count of a reference picture or adifference value between the first prediction sample and the secondprediction sample on a diagonal boundary.

FIGS. 29 and 30 are diagrams showing an example in which a predictionsample is derived based on a weighted sum operation of the firstprediction sample and the second prediction sample. FIG. 29 illustratesa case in which a left triangular partition type is applied to a codingblock and FIG. 30 illustrates a case in which a right triangularpartition type is applied to a coding block. In addition, FIG. 29 (a)and FIG. 30 (a) are diagrams representing a prediction aspect for a lumacomponent and FIG. 29 (b) and the FIG. 30 (b) are diagrams representinga prediction aspect for a chroma component.

In shown diagrams, a number marked on a prediction sample around theboundary of the first prediction unit and the second prediction unitrepresents a weight which is applied to the first prediction sample. Inan example, when a number marked on a prediction sample is N, theprediction sample may be derived by applying a weight of N/8 to thefirst prediction sample and applying a weight of (1−(N/8)) to the secondprediction sample.

In a non-boundary region, the first prediction sample or the secondprediction sample may be determined as a prediction sample. Looking atan example in FIG. 29, the first prediction sample derived based on themotion information of the first prediction unit may be determined as aprediction sample in a region belonging to the first prediction unit. Onthe other hand, the second prediction sample derived based on the motioninformation of the second prediction unit may be determined as aprediction sample in a region belonging to the second prediction unit.

Looking at an example in FIG. 30, the first prediction sample derivedbased on the motion information of the first prediction unit may bedetermined as a prediction sample in a region where a sum of an x-axiscoordinate and a y-axis coordinate is smaller than the first thresholdvalue. On the other hand, the second prediction sample derived based onthe motion information of the second prediction unit may be determinedas a prediction sample in a region where a sum of an x-axis coordinateand a y-axis coordinate is greater than the second threshold value.

A threshold value determining a non-boundary region may be determinedbased on at least one of a size of a coding block, a shape of a codingblock or a color component. In an example, when a threshold value for aluma component is set to be N, a threshold value for a chroma componentmay be set to be N/2.

Prediction samples included in a boundary region may be derived based ona weighted sum operation of the first prediction sample and the secondprediction sample. In this case, weights applied to the first predictionsample and the second prediction sample may be determined based on atleast one of a position of a prediction sample, a size of a codingblock, a shape of a coding block or a color component.

In an example, as in an example shown in FIG. 29 (a), prediction sampleswith the same x-axis coordinate and y-axis coordinate may be derived byapplying the same weight to the first prediction sample and the secondprediction sample. Prediction samples that an absolute value of adifference between an x-axis coordinate and a y-axis coordinate is 1 maybe derived by setting a weight ratio applied to the first predictionsample and the second prediction sample as (3:1) or (1:3). In addition,prediction samples that an absolute value of a difference between anx-axis coordinate and a y-axis coordinate is 2 may be derived by settinga weight ratio applied to the first prediction sample and the secondprediction sample as (7:1) or (1:7).

Alternatively, as in an example shown in FIG. 29 (b), prediction sampleswith the same x-axis coordinate and y-axis coordinate may be derived byapplying the same weight to the first prediction sample and the secondprediction sample and prediction samples that an absolute value of adifference between an x-axis coordinate and a y-axis coordinate is 1 maybe derived by setting a weight ratio applied to the first predictionsample and the second prediction sample as (7:1) or (1:7).

In an example, as in an example shown in FIG. 30 (a), prediction samplesthat a sum of an x-axis coordinate and a y-axis coordinate is smallerthan a width or a height of a coding block by 1 may be derived byapplying the sample weight to the first prediction sample and the secondprediction sample. Prediction samples that a sum of an x-axis coordinateand a y-axis coordinate is the same as or smaller than a width or aheight of a coding block by 2 may be derived by setting a weight ratioapplied to the first prediction sample and the second prediction sampleas (3:1) or (1:3). Prediction samples that a sum of an x-axis coordinateand a y-axis coordinate is greater than a width or a height of a codingblock by 1 or smaller than a width or a height of a coding block by 3may be derived by setting a weight ratio applied to the first predictionsample and the second prediction sample as (7:1) or (1:7).

Alternatively, as in an example shown in FIG. 30 (b), prediction samplesthat a sum of an x-axis coordinate and a y-axis coordinate is smallerthan a width or a height of a coding block by 1 may be derived byapplying the sample weight to the first prediction sample and the secondprediction sample. Prediction samples that a sum of an x-axis coordinateand a y-axis coordinate is the same as or smaller than a width or aheight of a coding block by 2 may be derived by setting a weight ratioapplied to the first prediction sample and the second prediction sampleas (7:1) or (1:7).

In another example, a weight may be determined by considering a positionof a prediction sample or a shape of a coding block. Equation 4 toEquation 6 represent an example in which a weight is derived when a lefttriangular partition type is applied to a coding block. Equation 4represents an example of deriving a weight applied to the firstprediction sample when a coding block is square.w1=(x−y+4)/8  [Equation 4]

In Equation 4, x and y represent a position of a prediction sample. Whena coding block is non-square, a weight applied to the first predictionsample may be derived as in the following Equation 5 or Equation 6.Equation 5 represents a case in which a width of a coding block isgreater than a height and Equation 6 represents a case in which a widthof a coding block is smaller than a height.w1=((x/whRatio)−y+4)/8  [Equation 5]w1=(x−(y*whRatio)+4)/8  [Equation 6]

When a right triangular partition type is applied to a coding block, aweight applied to the first prediction sample may be determined as inEquation 7 to Equation 9. Equation 7 represents an example of deriving aweight applied to the first prediction sample when a coding block issquare.w1=(CbW−1−x−y)±4)/8  [Equation 7]

In Equation 7, CbW represents a width of a coding block. When a codingblock is non-square, a weight applied to the first prediction sample maybe derived as in the following Equation 8 or Equation 9. Equation 8represents a case in which a width of a coding block is greater than aheight and Equation 9 represents a case in which a width of a codingblock is smaller than a height.w1=(CbH−1−(x/whRatio)−y)−(4)/8  [Equation 8]w1=(CbW−1−x−(y*whRatio)+(4)/8  [Equation 9]

In Equation 8, CbH represents a height of a coding block.

As in a shown example, prediction samples included in the firstprediction unit among prediction samples in a boundary region may bederived by giving a larger weight to the first prediction sample thanthe second prediction sample and prediction samples included in thesecond prediction unit among prediction samples in the boundary regionmay be derived by giving a larger weight to the second prediction samplethan the first prediction sample.

When diagonal partitioning is applied to a coding block, a combinedprediction mode that an intra prediction mode and a merge mode arecombined may be set not to be applied to a coding block.

When encoding/decoding of a coding block is completed, the motioninformation of a coding block that encoding/decoding is completed may bestored for the encoding/decoding of a subsequent coding block. Motioninformation may be stored in a unit of a sub-block with a preset size.In an example, a sub-block with a preset size may have a 4×4 size.Alternatively, according to a size or a shape of a coding block, a sizeor a shape of a sub-block may be differently determined.

When a sub-block belongs to the first prediction unit, the motioninformation of the first prediction unit may be stored as the motioninformation of a sub-block. On the other hand, when a sub-block belongsto the second prediction unit, the motion information of the secondprediction unit may be stored as the motion information of a sub-block.

When a sub-block is on the boundary of the first prediction unit and thesecond prediction unit, any one of the motion information of the firstprediction unit and the motion information of the second prediction unitmay be set as the motion information of a sub-block. In an example, themotion information of the first prediction unit may be set as the motioninformation of a sub-block or the motion information of the secondprediction unit may be set as the motion information of a sub-block.

In another example, when a sub-block is on the boundary of the firstprediction unit and the second prediction unit, any one of L0 motioninformation and L1 motion information of a sub-block may be derived fromthe first prediction unit and the other of L0 motion information and L1motion information of a sub-block may be derived from the secondprediction unit. In an example, the L0 motion information of the firstprediction unit may be set as the L0 motion information of a sub-blockand the L1 motion information of the second prediction unit may be setas the L1 motion information of a sub-block. But, when the firstprediction unit and the second prediction unit have only L0 motioninformation or only L1 motion information, the motion information of asub-block may be determined by selecting any one of the first predictionunit or the second prediction unit. Alternatively, a motion vectoraverage value of the first prediction unit and the second predictionunit may be set as a motion vector of a sub-block.

The motion information of a coding block that encoding/decoding iscompleted may be updated in a motion information table. In this case,the motion information of a coding block to which prediction unitpartitioning is applied may be set not to be added to a motioninformation table.

Alternatively, only the motion information of any one of a plurality ofprediction units generated by partitioning a coding block may be addedto a motion information table. In an example, while the motioninformation of the first prediction unit may be added to a motioninformation table, the motion information of the second prediction unitmay not be added to a motion information table. In this case, aprediction unit which will be added to a motion information table may beselected based on at least one of a size of a coding block, a shape of acoding block, a size of a prediction unit, a shape of a prediction unitor whether a bidirectional prediction is performed for a predictionunit.

Alternatively, the motion information of each of a plurality ofprediction units generated by partitioning a coding block may be addedto a motion information table. In this case, the adding order for amotion information table may be predefined in an encoding device and adecoding device. In an example, the motion information of a predictionunit including a top-left sample or a bottom-left corner sample may beadded to a motion information table before the motion information of theother prediction unit. Alternatively, the adding order for a motioninformation table may be determined based on at least one of a mergeindex or a reference picture index of each prediction unit or amagnitude of a motion vector.

Alternatively, motion information combining the motion information ofthe first prediction unit and the motion information of the secondprediction unit may be added to a motion information table. Any one ofL0 motion information and L1 motion information of combined motioninformation may be derived from the first prediction unit and the otherof L0 motion information and L1 motion information may be derived fromthe second prediction unit.

Alternatively, based on whether a reference picture of the firstprediction unit is the same as a reference picture of the secondprediction unit, motion information which will be added to a motioninformation table may be determined. In an example, when a referencepicture of the first prediction unit is different from a referencepicture of the second prediction unit, the motion information of any oneof the first prediction unit and the second prediction unit or motioninformation combining the first prediction unit and the secondprediction unit may be added to a motion information table. On the otherhand, when a reference picture of the first prediction unit is the sameas a reference picture of the second prediction unit, an average of amotion vector of the first prediction unit and a motion vector of thesecond prediction unit may be added to a motion information table.

Alternatively, based on a size of a coding block, a shape of a codingblock or a partitioning shape of a coding block, a motion vector whichwill be added to a motion information table may be determined. In anexample, when right triangular partitioning is applied to a codingblock, the motion information of the first prediction unit may be addedto a motion information table. On the other hand, when left triangularpartitioning is applied to a coding block, the motion information of thesecond prediction unit may be added to a motion information table ormotion information combining the motion information of the firstprediction unit and the motion information of the second prediction unitmay be added to a motion information table.

A motion information table for storing the motion information of acoding block to which prediction unit partitioning is applied may beseparately defined. In an example, the motion information of a codingblock to which prediction unit partitioning is applied may be stored ina partitioning mode motion information table. A partitioning mode motioninformation table may be referred to as a triangular motion informationtable. In other words, the motion information of a coding block to whichprediction unit partitioning is not applied may be stored in a generalmotion information table and the motion information of a coding block towhich prediction unit partitioning is applied may be stored in apartitioning mode motion information table. Embodiments that motioninformation of a coding block to which prediction unit partitioningdescribed above is applied is added to a motion information table may beapplied for updating a partitioning mode motion information table. In anexample, the motion information of the first prediction unit, the motioninformation of the second prediction unit, motion information combiningthe motion information of the first prediction unit and the motioninformation of the second prediction unit and motion informationaveraging a motion vector of the first prediction unit and a motionvector of the second prediction unit may be added to a partitioning modemotion information table.

When prediction mode partitioning is not applied to a coding block, amerge candidate may be derived by using a general motion informationtable. On the other hand, when prediction mode partitioning is appliedto a coding block, a merge candidate may be derived by using apartitioning mode motion information table.

Intra-prediction is a method for performing prediction on a currentblock by using a reconstructed sample that has been alreadyencoded/decoded and which is around the current block. In thisconnection, a reconstructed sample before applying an in-loop filter maybe used for intra-prediction of the current block.

An intra-prediction method includes intra-prediction based on a matrixand intra-prediction according to a direction with a neighboringreconstruction sample. Information indicating an intra-prediction methodof a current block may be signaled in a bitstream. The information maybe a 1-bit flag. Alternatively, an intra-prediction of a current blockmay be determined on the basis of at least one of a position of thecurrent block, a size of the current block, a shape of the currentblock, or an intra-prediction method of a neighboring block. In anexample, when a current block is present crossing a picture boundary, itmay be set such that an intra-prediction method based on a matrix is notapplied to the current block.

An intra-prediction method based on a matrix is a method of obtaining aprediction block of a current block on the basis of a matrix product ofa matrix stored in the encoder and the decoder, and reconstructionsamples around the current block. Information for specifying any one ofa plurality of prestored matrices may be signaled in a bitstream. Thedecoder may determine a matrix for performing intra-prediction on acurrent block on the basis of the above information and a size of thecurrent block.

General intra-prediction is a method of obtaining a prediction block ofa current block on the basis of a non-directional intra-prediction modeor directional intra-prediction mode. Hereinafter, with reference to thefigure, a process of intra-prediction based on general intra-predictionwill be described.

FIG. 31 is a view of a flowchart showing an intra-prediction methodaccording to an embodiment of the present disclosure.

A reference sample line of a current block may be determined S3101. Thereference sample line means a group of reference samples included in ak-th spaced apart line from the top and/or the left of the currentblock. The reference sample may be derived from a reconstructed samplearound the current block which has been already encoded/decoded.

Index information identifying a reference sample line for the currentblock among the plurality of reference sample lines may be signaled in abitstream. In an example, index information, intra_luma_ref_idx, forspecifying the reference sample line for the current block may besignaled in a bitstream. The index information may be signaled on acoding block basis.

A plurality of reference sample lines may include at least one of afirst line, a second line, or a third line from a top and/or a left ofthe current block. A reference sample line consisted of a row adjacentto a top of the current block and a column adjacent to a left of thecurrent block among the plurality of reference sample lines may bereferred to as an adjacent reference sample line, and remainingreference sample lines may be referred to as non-adjacent referencesample lines.

Table 3 shows an index assigned to each of the candidate referencesample lines.

TABLE 3 Index (intra_luma_ref_idx) Reference sample line 0 Adjacentreference sample line 1 First non-adjacent reference sample line 2Second non-adjacent reference sample line

Based on at least one of the position, the size, the shape of a currentblock or the prediction encoding mode of a neighboring block thereto,the reference sample line for the current block may be determined. Inone example, when the current block adjoins a boundary of a picture, atile, a slice or a coding tree unit, the adjacent reference sample linemay be determined as the reference sample line for the current block.The reference sample line may include top reference samples located atthe top of the current block and left reference samples located at theleft of the current block. Top reference samples and left referencesamples may be derived from reconstructed samples around the currentblock. The reconstructed samples may be in a state before the in-loopfilter is applied.

Next, the intra prediction mode for the current block may be determinedS3102. In this connection, at least one of a non-directional intraprediction mode or a directional intra prediction mode may be determinedas the intra prediction mode for the current block. The non-directionalintra prediction mode includes a planar mode and a DC mode. Thedirectional intra prediction mode includes 33 or 65 modes from aleft-bottom diagonal direction to a right-top diagonal direction.

FIG. 32 is a diagram showing intra prediction modes.

FIG. 32 (a) shows 35 intra prediction modes. FIG. 32 (b) shows 67 intraprediction modes.

The larger or smaller number of intra prediction modes than the numberof those shown in FIG. 32 may be defined.

Based on an intra-prediction mode of a neighboring block adjacent to acurrent block, an MPM (Most Probable Mode) may be set. In thisconnection, a neighboring block may include a left neighboring blockadjacent to the left of the current block and a top neighboring blockadjacent to the top of the current block.

The number of MPMs included in an MPM list may be preset in an encodingdevice and a decoding device. In an example, the number of MPMs may be3, 4, 5, or 6. Alternatively, information representing the number ofMPMs may be signaled in a bitstream. Alternatively, the number of MPMsmay be determined based on at least one of a prediction encoding mode ofa neighboring block, a size, a shape or a reference sample line index ofa current block. In an example, while N MPMs may be used when anadjacent reference sample line is determined as a reference sample lineof a current block, M MPMs may be used when a non-adjacent referencesample line is determined as a reference sample line of a current block.As M is a natural number smaller than N, in an example, N may be 6 and Mmay be 5, 4, or 3. Accordingly, while an intra-prediction mode of acurrent block may be determined as any one of 6 candidateintra-prediction modes when an index of a reference sample line of acurrent block is 0 and an MPM flag is true, an intra-prediction mode ofa current block may be determined as any one of 5 candidateintra-prediction modes when an index of a reference sample line of acurrent block is greater than 0 and an MPM flag is true.

Alternatively, the fixed number (e.g., 6 or 5) of MPM candidates may beused regardless of an index of a reference sample line of a currentblock.

When matrix-based intra-prediction is applied to a neighboring block, anintra-prediction mode of a neighboring block may be considered as aPlanar and an MPM candidate may be derived.

When intra BDPCM is applied to a neighboring block, an intra-predictionmode of a neighboring block may be considered as a default mode and anMPM candidate may be derived. In this case, a default mode may be atleast one of a DC, a Planar, a vertical direction or a horizontaldirection.

Alternatively, based on an intra BDPCM application direction of aneighboring block, an intra-prediction mode of a neighboring block maybe determined. In an example, when intra BDPCM in a horizontal directionis applied to a neighboring block, an intra-prediction mode of aneighboring block may be considered to have a horizontal direction. Onthe other hand, when intra BDPCM in a vertical direction is applied to aneighboring block, an intra-prediction mode of a neighboring block maybe considered to have a vertical direction.

An MPM list including a plurality of MPMs may be generated andinformation representing whether the same MPM as an intra-predictionmode of a current block is included in an MPM list may be signaled in abitstream. As the information is a 1-bit flag, it may be referred to asan MPM flag. When the MPM flag represents that the same MPM as a currentblock is included in an MPM list, index information identifying one ofMPMs may be signaled in a bitstream. In an example, index information,mpm_idx, specifying any one of a plurality of MPMs may be signaled in abitstream. An MPM specified by the index information may be set as anintra-prediction mode of a current block. When the MPM flag representsthat the same MPM as current block is not included in an MPM list,remaining mode information indicating any one of remainingintra-prediction modes excluding MPMs may be signaled in a bitstream.Remaining mode information indicates an index value corresponding to anintra-prediction mode of a current block among remainingintra-prediction modes in which indexes are reassigned excluding MPMs.The decoding device arranges MPMs in ascending order, and determine anintra-prediction mode of a current block by comparing remaining modeinformation with MPMs. In an example, when remaining mode information isthe same as or smaller than an MPM, an intra-prediction mode of acurrent block may be derived by adding 1 to residual mode information.

When an intra-prediction mode of a current block is derived, acomparison between part of MPMs and remaining mode information may beomitted. In an example, MPMs which are a non-directionalintra-prediction mode among MPMs may be excluded from a comparisontarget. When non-directional intra-prediction modes are set as MPMs, itis clear that remaining mode information indicates a directionalintra-prediction mode, so an intra-prediction mode of a current blockmay be derived by comparing remining MPMs excluding nondirectionalintra-prediction modes with residual mode information. Instead ofexcluding non-directional intra-prediction modes from a comparisontarget, the number of non-directional intra-prediction modes may beadded to remining mode information to compare a result value thereonwith remining MPMs.

Instead of setting a default mode as an MPM, information representingwhether an intra-prediction mode of a current block is a default modemay be signaled in a bitstream. The information may be a 1-bit flag andthe flag may be referred to as a default mode flag. The default modeflag may be signaled only when an MPM flag represents that the same MPMas a current block is included in an MPM list. As mentioned above, adefault mode may include at least one of a Planar, a DC, a verticaldirection mode or a horizontal direction mode. In an example, when aplanar is set as a default mode, a default mode flag may indicatewhether an intra-prediction mode of a current block is a planar. When adefault mode flag indicates that an intra-prediction mode of a currentblock is not a default mode, one of MPMs indicated by index informationmay be set as an intra-prediction mode of a current block.

When a default mode flag is used, the same intra-prediction mode as adefault mode may be set not to be set as an MPM. In an example, when adefault mode flag indicates whether an intra-prediction mode of acurrent block is a planar, an intra-prediction mode of a current blockmay be derived by using 5 MPMs excluding an MPM corresponding to aplanar.

When a plurality of intra-prediction modes are set as default modes,index information indicating any one of default modes may be furthersignaled. An intra-prediction mode of a current block may be set as adefault mode indicated by the index information.

When an index of a reference sample line of a current block is not 0, itmay be set not to use a default mode. In an example, when a non-adjacentreference sample line is determined as a reference sample line of acurrent block, it may be set not to use a non-directionalintra-prediction mode such as a DC mode or a planar mode. Accordingly,when an index of a reference sample line is not 0, a default mode flagmay not be signaled and a value of the default mode flag may be inferredas a predefined value (i.e., false).

When an intra-prediction mode for the current block is determined,prediction samples for the current block may be obtained based on thedetermined intra-prediction mode S3503.

In case that the DC mode is selected, prediction samples for a currentblock are generated based on the average value of the reference samples.In detail, values of all of samples within the prediction block may begenerated based on an average value of the reference samples. An averagevalue may be derived using at least one of top reference samplesadjacent to the top of the current block, and left reference samplesadjacent to the left of the current block.

The number or a range of the reference samples used when deriving anaverage value may vary based on the shape of the current block. In anexample, when a current block is a non-square block where a width isgreater than a height, an average value may be calculated by using topreference samples. To the contrary, when a current block is a non-squareblock where a width is smaller than a height, an average value may becalculated by using left reference samples. In other words, when a widthand a height of the current block are different, reference samplesadjacent to the greater length may be used so as to calculate an averagevalue. Alternatively, whether to calculate an average value by using topreference samples or by using left reference samples may be determinedon the basis of a ratio between a width and a height of the currentblock.

When a planar mode is selected, a prediction sample may be obtained byusing a horizontal directional prediction sample and a verticaldirectional prediction sample. In this connection, the horizontaldirectional prediction sample may be obtained on the basis of a leftreference sample and a right reference sample which are positioned atthe same horizontal line with the prediction sample, and the verticaldirectional prediction sample may be obtained on the basis of an topreference sample and a bottom reference sample which are positioned atthe same vertical line with the prediction sample. In this connection,the right reference sample may be generated by copying a referencesample adjacent to the top-right corner of the current block, and thebottom reference sample may be generated by copying a reference sampleadjacent to the lower-left corner of the current block. The horizontaldirectional prediction sample may be obtained on the basis of a weightedsum of the left reference sample and the right reference sample, and thevertical directional prediction sample may be obtained on the basis of aweighted sum of the top reference sample and the bottom referencesample. In this connection, a weighting factor assigned to eachreference sample may be determined according to a position of theprediction sample. The prediction sample may be obtained on the basis ofan average or a weighted sum of the horizontal directional predictionsample and the vertical directional prediction sample. When a weightedsum is used, a weighting factor assigned to the horizontal directionalprediction sample and the vertical directional prediction sample may bedetermined on the basis of a position of the prediction sample.

When a directional prediction mode is selected, a parameter representinga prediction direction (or prediction angle) of the selected directionalprediction mode may be determined. Table 4 below represents an intradirectional parameter of intraPredAng for each intra-prediction mode.

TABLE 4 PredModeIntra 1 2 3 4 5 6 7 IntraPredAng — 32 26 21 17 13 9PredModeIntra 8 9 10 11 12 13 14 IntraPredAng 5 2 0 −2 −5 −9 −13PredModeIntra 15 16 17 18 19 20 21 IntraPredAng −17 −21 −26 −32 −26 −21−17 PredModeIntra 22 23 24 25 26 27 28 IntraPredAng −13 −9 −5 −2 0 2 5PredModeIntra 29 30 31 32 33 34 IntraPredAng 9 13 17 21 26 32

Table 4 represents an intra directional parameter of eachintra-prediction mode where an index thereof is one of 2 to 34 when 35intra-prediction modes are defined. When directional intra-predictionmodes are defined more than 33, an intra directional parameter of eachintra-prediction mode may be set by subdividing Table 4. Top referencesamples and left reference samples for the current block are arranged ina line, and then a prediction sample may be obtained on the basis of avalue of an intra directional parameter. In this connection, when avalue of the intra directional parameter is a negative value, leftreference samples and top reference samples may be arranged in a line.

FIGS. 33 and 34 are a diagram showing an example of a one-dimensionalarray which arranges reference samples in a line.

FIG. 33 shows an example of a one-dimensional array in a verticaldirection which reference samples are arranged in a vertical directionand FIG. 34 shows an example of a one-dimensional array in a horizontaldirection which reference samples are arranged in a horizontaldirection. An embodiment of FIGS. 33 and 34 is described by assuming acase in which 35 intra-prediction modes are defined.

When an intra-prediction mode index is any one of 11 to 18, aone-dimensional array in a horizontal direction which rotates topreference samples counterclockwise may be applied and when anintra-prediction mode index is any one of 19 to 25, a one-dimensionalarray in a vertical direction which rotates left reference samplesclockwise may be applied. In arranging reference samples in a line, anintra-prediction mode angle may be considered.

Based on an intra directional parameter, a reference sampledetermination parameter may be determined. A reference sampledetermination parameter may include a reference sample index forspecifying a reference sample and a weight parameter for determining aweight applied to a reference sample.

A reference sample index, iIdx, and a weighting factor parameter, ifact,may be respectively obtained through Equations 10 and 11 below.iIdx=(y+1)*P _(ang)/32  [Equation 10]i _(fact)=[(y+1)*P _(ang)]&31  [Equation 11]

In Equations 10 and 11, P_(ang) represents an intra directionalparameter. A reference sample specified by a reference sample index ofiIdx corresponds to an integer pel.

In order to derive a prediction sample, at least one reference samplemay be specified. In detail, according to a slope of a prediction mode,a position of a reference sample used for deriving a prediction samplemay be specified. In an example, a reference sample used for deriving aprediction sample may be specified by using a reference sample index ofiIdx.

In this connection, when a slope of an intra-prediction mode is notrepresented by one reference sample, a prediction sample may begenerated by performing interpolation on a plurality of referencesamples. In an example, when a slope of an intra-prediction mode is avalue between a slope between a prediction sample and a first referencesample, and a slope between the prediction sample and a second referencesample, the prediction sample may be obtained by performinginterpolation on the first reference sample and the second referencesample. In other words, when an angular line according to anintra-prediction angle does not pass a reference sample positioned at aninteger pel, a prediction sample may be obtained by performinginterpolation on reference samples positioned adjacent to the left andthe right, or the top and the bottom of the position where the angularline passes.

Equation 12 below represents an example of obtaining a prediction sampleon the basis of reference samples.P(x,y)=((32−i _(fact))/32)*Ref_1D(x+iIdx+1)+(i_(fact)/32)*Ref_1D(x+iIdx+2)  [Equation 12]

In Equation 12, P represents a prediction sample, and Ref_1D representsany one of reference samples that are arranged in a line. In thisconnection, a position of the reference sample may be determined by aposition (x, y) of the prediction sample and a reference sample index ofiIdx.

When a slope of an intra-prediction mode is possibly represented by onereference sample, a weighting factor parameter of ifact is set to 0.Accordingly, Equation 12 may be simplified as Equation 13 below.P(x,y)=Ref_1D(x+iIdx+1)  [Equation 13]

Based on a plurality of intra-prediction modes, intra-prediction for acurrent block may be performed. In an example, an intra-prediction modemay be derived per prediction sample and a prediction sample may bederived based on an intra-prediction mode assigned thereto.

Alternatively, an intra-prediction mode may be derived per region andintra-prediction for each region may be performed based on anintra-prediction mode assigned thereto. In this case, the region mayinclude at least one sample. At least one of a size or a shape of theregion may be adaptively determined based on at least one of a size or ashape of a current block or an intra-prediction mode. Alternatively, atleast one of a size or a shape of a region may be predefinedindependently in an encoding device and a decoding device regardless ofa size or a shape of a current block.

FIG. 35 is a diagram illustrating an angle formed by directionalintra-prediction modes with a straight line parallel to an x-axis.

As in an example shown in FIG. 35, directional prediction modes mayexist between a bottom-left diagonal direction and a top-right diagonaldirection. As described by an angle formed by an x-axis and adirectional prediction mode, directional prediction modes may existbetween 45 degrees (a bottom-left diagonal direction) and −135 degrees(a top-right diagonal direction).

When a current block is a non-square, a case may be present where aprediction sample is derived by using, among reference samplespositioned at the angular line according to an intra-prediction angle, areference sample that is positioned farther than a reference sampleclose to a prediction sample according to an intra-prediction mode forthe current block.

FIG. 36 is a diagram showing an aspect in which a prediction sample isobtained when a current block has a non-square shape.

In an example, as in an example shown in FIG. 36 (a), it is assumed thata current block has a non-square shape whose width is greater than aheight and an intra-prediction mode of a current block is a directionalintra-prediction mode with an angle from 0 degrees to 45 degrees. In thecase, when a prediction sample A near a right column of a current blockis derived, there may occur a case in which a left reference sample Lfar from the prediction sample is used instead of a top reference sampleT close to the prediction sample among reference samples positioned inan angular mode following the angle.

In another example, as in an example shown in FIG. 36 (b), it is assumedthat a current block has a non-square shape whose height is greater thana width and an intra-prediction mode of a current block is a directionalintra-prediction mode from −90 degrees to −135 degrees. In the case,when a prediction sample A near a bottom row of a current block isderived, there may occur a case in which a top reference sample T farfrom the prediction sample is used instead of a left reference sample Lclose to the prediction sample among reference samples positioned in anangular mode following the angle.

To solve the above problem, when a current block is a non-square, anintra-prediction mode for the current block may be substituted with anintra-prediction mode in opposite direction. Accordingly, for anon-square block, directional prediction modes having angles greater orsmaller than those of directional prediction modes shown in FIG. 32 maybe used. The above directional intra-prediction mode may be defined as awide angle intra-prediction mode. A wide angle intra-prediction moderepresents a directional intra-prediction mode that does not belong to arange of 45 degrees to −135 degrees.

FIG. 37 is a view showing wide angle intra-prediction modes.

In an example show in FIG. 37, intra-prediction modes having indicesfrom −1 to −14 and intra-prediction modes having indices from 67 to 80represent wide angle intra-prediction modes.

In FIG. 37, 14 wide angle intra-prediction modes (from −1 to −14) whichare greater in angle than 45 degrees and 4 wide angle intra-predictionmodes (from 67 to 80) which are smaller in angle than −135 degrees areshown. However, more or fewer number of wide angle intra-predictionmodes may be defined.

When a wide angle intra-prediction mode is used, a length of topreference samples may be set to 2W+1, and a length of left referencesamples may be set to 2H+1.

As a wide angle intra-prediction mode is used, a sample A shown in FIG.37 (a) may be predicted by using a reference sample T and a sample Ashown in FIG. 37 (b) may be predicted by using a reference sample L.

A total of 67+N intra-prediction modes may be used constituted with theexisting intra-prediction modes in addition to N wide angleintra-prediction modes. In an example, Table 5 represents an intradirectional parameter of intra-prediction modes when 20 wide angleintra-prediction modes are defined.

TABLE 5 PredModeIntra −10 −9 −8 −7 −6 −5 −4 −3 −2 intraPredAngle 114 9379 68 60 54 49 45 39 PredModeIntra −1 2 3 4 5 6 7 8 9 intraPredAngle 3532 29 26 23 21 19 17 15 PredModeIntra 10 11 12 13 14 15 16 17 18intraPredAngle 13 11 9 7 5 3 2 1 0 PredModeIntra 19 20 21 22 23 24 25 2627 intraPredAngle −1 −2 −3 −5 −7 −9 −11 −13 −15 PredModeIntra 28 29 3031 32 33 34 35 36 intraPredAngle −17 −19 −21 −23 −26 −29 −32 −29 −26PredModeIntra 37 38 39 40 41 42 43 44 45 intraPredAngle −23 −21 −19 −17−15 −13 −11 −9 −7 PredModeIntra 46 47 48 49 50 51 52 53 54intraPredAngle −5 −3 −2 −1 0 1 2 3 5 PredModeIntra 55 56 57 58 59 60 6162 63 intraPredAngle 7 9 11 13 15 17 19 21 23 PredModeIntra 64 65 66 6768 69 70 71 72 intraPredAngle 26 29 32 35 39 45 49 54 60 PredModeIntra73 74 75 76 intraPredAngle 68 79 93 114

When a current block is non-square and an intra-prediction mode of acurrent block obtained in S2502 belongs to a conversion range, anintra-prediction mode of a current block may be converted into a wideangle intra-prediction mode. The conversion range may be determinedbased on at least one of a size or a shape or a ratio of a currentblock. In this connection, the ratio may represent a ratio between awidth and a height of a current block. When a current block has anon-square shape whose a width is greater than a height, a conversionrange may be set from an intra-prediction mode index in a top-rightdiagonal direction (e.g., 66) to (subtracting N from an index of anintra-prediction mode in a top-right diagonal direction). In this case,N may be determined based on a ratio of a current block. When anintra-prediction mode of a current block belongs to a conversion range,the intra-prediction mode may be converted into a wide angleintra-prediction mode. The conversion may be performed by subtracting apredefined value from the intra-prediction mode, and the predefinedvalue may be a total number of intra-prediction modes excluding wideangle intra-prediction modes (e.g., 67).

By the embodiment, each of intra-prediction modes between No. 66 to No.53 may be converted into wide angle intra-prediction modes between No.−1 to No. −14, respectively.

When a current block has a non-square shape whose height is greater thana width, a conversion range may be set from an intra-prediction modeindex in a bottom-left diagonal direction (e.g., 2) to (an index of anintra-prediction mode in a bottom-left diagonal direction+M). In thiscase, M may be determined based on a ratio of a current block. When anintra-prediction mode of a current block belongs to a conversion range,the intra-prediction mode may be converted into a wide angleintra-prediction mode. The conversion may be performed by adding apredefined value to the intra-prediction mode, and the predefined valuemay be a total number of directional intra-prediction modes excludingwide angle intra-prediction modes (e.g., 65).

By the embodiment, each of intra-prediction modes between No. 2 to No.15 may be converted into wide angle intra-prediction modes between No.67 to No. 80, respectively.

Hereinafter, intra-prediction modes belonging to a conversion range arereferred to as a wide angle replaced intra-prediction mode.

A conversion range may be determined based on a ratio of a currentblock. In an example, Table 6 and Table 7 represent a conversion rangewhen 35 intra-prediction modes are defined and when 67 intra-predictionmodes are defined excluding a wide angle intra-prediction mode,respectively.

TABLE 6 Condition Replaced Intra Prediction Modes W/H = 2 Modes 2, 3, 4W/H > 2 Modes 2, 3, 4, 5, 6 W/H = 1 None H/W = 1/2 Modes 32, 33, 34 H/W< 1/2 Modes 30, 31, 32, 33, 34

TABLE 7 Condition Replaced Intra Prediction Modes W/H = 2 Modes 2, 3, 4,5, 6, 7 W/H > 2 Modes 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 W/H = 1 None H/W =1/2 Modes 61, 62, 63, 64, 65, 66 H/W < 1/2 Modes 57, 58, 59, 60, 61, 62,63, 64, 65, 66

As in an example shown in Table 6 and Table 7, according to a ratio of acurrent block, the number of wide angle replaced intra-prediction modesincluded in a conversion range may vary. A conversion range may befurther subdivided as in Table 8 below by subdividing a ratio of acurrent block.

TABLE 8 Condition Replaced Intra Prediction Modes W/H = 16 Modes 12, 13,14, 15 W/H = 8 Modes 12, 13 W/H = 4 Modes 2, 3, 4, 5, 6, 7, 8, 9, 10, 11H/W = 2 Modes 2, 3, 4, 5, 6, 7 H/W = 1 None W/H = 1/2 Modes 61, 62, 63,64, 65, 66 W/H = 1/4 Modes 57, 58, 59, 60, 61, 62, 63, 64, 65, 66 W/H =1/8 Modes 55, 56 H/W = 1/16 Modes 53, 54, 55, 56

When a non-adjacent reference sample line is determined as a referencesample line of a current block, or when a multi-line intra-predictionencoding method selecting any one of a plurality of reference samplelines is used, it may be set not to use a wide angle intra-predictionmode. In other words, although a current block is non-square and anintra-prediction mode of a current block belongs to a conversion range,an intra-prediction mode of a current block may not be converted into awide angle intra-prediction mode. Alternatively, when anintra-prediction mode of a current block is determined as a wide angleintra-prediction mode, it may set to make non-adjacent reference samplelines unavailable as a reference sample line of a current block, or notto use a multi-line intra-prediction encoding method selecting any oneof a plurality of reference sample lines. When a multi-lineintra-prediction encoding method is not used, an adjacent referencesample line may be determined as a reference sample line of a currentblock.

When a wide angle intra-prediction mode is not used, refW and refH maybe set as a sum of nTbW and nTbH. Accordingly, a non-adjacent referencesample whose distance with a current block is i may include(nTbW+nTbH+offsetX[i]) top reference samples and (nTbW+nTbH+offsetY[i])left reference samples except a top-left reference sample. In otherwords, a non-adjacent reference sample whose distance with a currentblock is i may include (2nTbW+2nTbH+offsetX[i]+offsetY[i]+1) referencesamples. For example, when a value of whRatio is greater than 1, a valueof offsetX may be set to be larger than that of offsetY. In an example,a value of offsetX may be set to be 1 and a value of offsetY may be setto be 0. On the other hand, when a value of whRatio is smaller than 1, avalue of offsetY may be set to be larger than that of offsetX. In anexample, a value of offsetX may be set to be 0 and a value of offsetYmay be set to be 1.

As wide angle intra-prediction modes are used in addition to theexisting intra-prediction modes, a resource needed to encode wide angleintra-prediction modes may be increased and encoding efficiency may bereduced. Accordingly, instead of encoding wide angle intra-predictionmodes as they are, replaced intra-prediction modes for wide angleintra-prediction modes may be encoded to improve encoding efficiency.

In an example, when a current block is encoded by using a wide angleintra-prediction mode of No. 67, No. 2, a wide angle replacedintra-prediction mode of No. 67, may be encoded as an intra-predictionmode of a current block. In addition, when a current block is encoded asa wide angle intra-prediction mode of No. −1, No. 66, an wide anglereplaced intra-prediction mode of No. −1, may be encoded as anintra-prediction mode of a current block.

A decoding device may decode an intra-prediction mode of a current blockand judge whether a decoded intra-prediction mode is included in aconversion range. When a decoded intra-prediction mode is a wide anglereplaced intra-prediction mode, an intra-prediction mode may beconverted into a wide angle intra-prediction mode.

Alternatively, when a current block is encoded as a wide angleintra-prediction mode, a wide angle intra-prediction mode may be encodedas it is.

Encoding of an intra prediction mode may be performed based on theabove-described MPM list. Concretely, when a neighboring block isencoded as a wide angle intra-prediction mode, an MPM may be set basedon a wide angle replaced intra-prediction mode corresponding to the wideangle intra prediction mode.

A coding block or a transform block may be partitioned into a pluralityof sub-blocks (or sub-partitions). When a coding block or a transformblock is partitioned into a plurality of sub-blocks, prediction,transform and quantization may be performed for each sub-block.Partitioning a coding block or a transform block into a plurality ofsub-blocks may be defined as a sub-partition intra encoding method.

Information representing whether a sub-partition intra encoding methodis applied may be signaled in a bitstream. The information may be a1-bit flag. In an example, a syntax element,‘intra_subpartitions_mode_flag’, representing whether a coding block ora transform block is partitioned into a plurality of sub-blocks may besignaled in a bitstream.

Alternatively, whether a sub-partition intra encoding method is appliedmay be determined based on at least one of a size, a shape or anintra-prediction mode of a coding block or a transform block. In anexample, when an intra-prediction mode of a coding block is anon-directional intra-prediction mode (e.g., a planar or a DC) or apredefined directional intra-prediction mode (e.g., an intra-predictionmode in a horizontal direction, an intra-prediction mode in a verticaldirection or an intra-prediction mode in a diagonal direction), it mayset not to apply a sub-partition intra encoding method. Alternatively,when a size of a coding block is smaller than a threshold value, it mayset not to apply a sub-partition intra encoding method.

Alternatively, when intra-prediction for a sub-block is performed basedon an intra-prediction mode of a coding block, whether a sub-partitionintra encoding method is applied may be determined based on whether areconstructed sample included in a neighboring sub-block should be usedas a reference sample for intra-prediction of a sub-block. In anexample, when an intra-prediction mode of a coding block is anintra-prediction mode in a diagonal direction or a wide angleintra-prediction mode and a neighboring sub-block cannot be utilized asa reference sample in performing intra-prediction for a sub-block basedon the intra-prediction mode, it may set not to use a sub-partitionintra encoding method.

Alternatively, when a height and width ratio of a coding block is equalto or greater than a threshold value or equal to or less than athreshold value, it may set not to use a sub-partition intra encodingmethod. Alternatively, when at least one of a height or a width of acoding block is equal to or less than a threshold value, it may set notto use a sub-partition intra encoding method. In an example, when awidth or a height of a coding block is equal to or less than a thresholdvalue or when both a height and a width of a coding block is equal to orless than a threshold value, a sub-partition intra encoding method maynot be used. Alternatively, when the number of samples included in acoding block is equal to or less than a threshold value, a sub-partitionintra encoding method may not be used. A threshold value may have apredefined value in an encoding device and a decoding device.Alternatively, information for determining a threshold value may besignaled in a bitstream.

Alternatively, whether to signal a flag indicating whether asub-partition intra encoding method is applied or not may be determinedbased on at least one of a size, a shape or an intra-prediction mode ofa coding block or a transform block. In an example, only when both aheight and a width of a coding block is equal to or less than athreshold value and/or when a size of a coding block is equal to orgreater than a threshold value, a flag indicating whether asub-partition intra encoding method is applied or not may be encoded andsignaled. When a flag indicating whether a sub-partition intra encodingmethod is applied or not is not encoded, a sub-partition intra encodingmethod may not be applied.

When a sub-partition intra encoding method is not used, signaling of asyntax element, intra_subpartitions_mode_flag, may be omitted. Whensignaling of the flag is omitted, the flag may be considered to indicatethat a sub-partition intra encoding method is not applied.

When a sub-partition intra encoding method is applied, a partitioningtype of a coding block or a transform block may be determined. In thiscase, a partitioning type represents a partitioning direction of acoding block or a transform block. In an example, partitioning in avertical direction may mean that a coding block or a transform block ispartitioned by using at least one vertical line and partitioning in ahorizontal direction may mean that a coding block or a transform blockis partitioned by using at least one horizontal line.

FIG. 38 is a diagram showing an example of vertical directionalpartitioning and horizontal directional partitioning.

FIG. 38 (a) represents an example in which a coding block is partitionedinto 2 sub-blocks and FIG. 38 (b) represents an example in which acoding block is partitioned into 4 sub-blocks.

Information for determining a partitioning type of a coding block or atransform block may be signaled in a bitstream. In an example,information representing whether vertical directional partitioning isapplied to a coding block or a transform block or whether horizontaldirectional partitioning is applied to a coding block or a transformblock may be signaled. The information may be a 1-bit flag,intra_subpart_type_flag. When a value of the flag is 1, it representsthat a coding block or a transform block is partitioned in a horizontaldirection and when a value of the flag is 0, it represents that a codingblock or a transform block is partitioned in a vertical direction.

Alternatively, a partitioning type of a coding block or a transformblock may be determined based on a size, a shape or an intra-predictionmode of a coding block or a transform block. In an example, apartitioning type of a coding block may be determined based on a widthand height ratio of a coding block. For example, when a value of whRatiorepresenting a height and width ratio of a coding block is equal to orgreater than the first threshold value, vertical directionalpartitioning may be applied to a coding block. Otherwise, horizontaldirectional partitioning may be applied to a coding block.

FIG. 39 is a diagram showing an example in which a partitioning type ofa coding block is determined.

For convenience of description, it is assumed that the first thresholdvalue is 2. In an example shown in FIG. 39 (a), whRatio of a codingblock is 1, which is smaller than the first threshold value.Accordingly, encoding of information representing a partitioning type ofa coding block may be omitted and horizontal directional partitioningmay be applied to a coding block.

In an example shown in FIG. 39 (b), whRatio of a coding block is 2,which is the same as the first threshold value. Accordingly, encoding ofinformation representing a partitioning type of a coding block may beomitted and vertical directional partitioning may be applied to a codingblock.

A partitioning type of a coding block may be determined by using thesecond threshold value whose sign is opposite to the first thresholdvalue. In an example, when a value of whRatio is equal to or less thanthe second threshold value, horizontal directional partitioning may beapplied to a coding block and otherwise, vertical directionalpartitioning may be applied to a coding block. An absolute value of thefirst threshold value and the second threshold value may be the same andtheir signs may be different. In an example, when the first thresholdvalue is N (in this case, N is an integer such as 1, 2, 4, etc.), thesecond threshold value may be −N.

FIG. 40 is a diagram showing an example in which a partitioning type ofa coding block is determined.

For convenience of description, it is assumed that the second thresholdvalue is −2. In an example shown in FIG. 40 (a), whRatio of a codingblock is −1, which is greater than the second threshold value.Accordingly, encoding of information representing a partitioning type ofa coding block may be omitted and vertical directional partitioning maybe applied to a coding block.

In an example shown in FIG. 40 (b), whRatio of a coding block is −2,which is the same as the second threshold value. Accordingly, encodingof information representing a partitioning type of a coding block may beomitted and horizontal directional partitioning may be applied to acoding block.

Alternatively, a partitioning type of a coding block may be determinedbased on the first threshold value and the second threshold value. In anexample, when a value of whRatio is equal to or greater than the firstthreshold value, horizontal directional partitioning may be applied to acoding block and when a value of whRatio is equal to or less than thesecond threshold value, vertical directional partitioning may be appliedto a coding block. When a value of whRatio exists between the firstthreshold value and the second threshold value, a partitioning type of acoding block may be determined by parsing information in a bitstream.

The first threshold value and the second threshold value may bepredefined in an encoding device and a decoding device. Alternatively,the first threshold value and the second threshold value may be definedper sequence, picture or slice.

Alternatively, a partitioning type may be determined based on a size ofa coding block or a transform block. In an example, when a size of acoding block is N×n, vertical directional partitioning may be appliedand when a size of a coding block is n×N, horizontal directionalpartitioning may be applied. In this case, n may be a natural numbersmaller than N. N and/or n may be a predefined value in an encodingdevice and a decoding device. Alternatively, information for determiningN and/or n may be signaled in a bitstream. In an example, N may be 32,64, 128 or 256, etc. Accordingly, when a size of a coding block is 128×n(in this case, n is a natural number such as 16, 32 or 64, etc.),vertical directional partitioning may be applied and when a size of acoding block is n×128, horizontal directional partitioning may beapplied.

Alternatively, a partitioning type of a coding block or a transformblock may be determined based on an intra-prediction mode of a codingblock or a transform block. In an example, when an intra-prediction modeof a coding block has a horizontal direction or has a direction similarto the horizontal direction, vertical directional partitioning may beapplied to a coding block. In this case, an intra-prediction mode havinga direction similar to the horizontal direction represents anintra-prediction mode (e.g., INTRA_ANGULAR18±N) that an index differencevalue with an intra-prediction mode in a horizontal direction (e.g.,INTRA_ANGULAR18 shown in FIG. 32 (b)) is equal to or less than athreshold value. On the other hand, when an intra-prediction mode of acoding block has a vertical direction or has a direction similar to thevertical direction, horizontal directional partitioning may be appliedto a coding block. In this case, an intra-prediction mode having adirection similar to the vertical direction represents anintra-prediction mode (e.g., INTRA_ANGULAR50±N) that an index differencevalue with an intra-prediction mode in a vertical direction (e.g.,INTRA_ANGULAR50 shown in FIG. 32 (b)) is equal to or less than athreshold value. In this case, a threshold value N may be a predefinedvalue in an encoding device and a decoding device. Alternatively,information for determining a threshold value N may be signaled in asequence level, a picture level or a slice level.

FIG. 41 is a diagram showing an example in which a partitioning type ofa coding block is determined based on an intra-prediction mode of acoding block.

As in an example shown in FIG. 41 (a), when an intra-prediction mode ofa coding block has a direction similar to a vertical direction,horizontal directional partitioning may be applied to a coding block.

On the other hand, as in an example shown in FIG. 41 (b), when anintra-prediction mode of a coding block has a direction similar to ahorizontal direction, vertical directional partitioning may be appliedto a coding block.

Contrary to a shown example, when an intra-prediction mode of a codingblock has a horizontal direction or has a direction similar to ahorizontal direction, horizontal directional partitioning may beapplied, and when an intra-prediction mode of a coding block has avertical direction or has a direction similar to a vertical direction,vertical directional partitioning may be applied.

When vertical directional partitioning or horizontal directionalpartitioning is applied, a partitioning type of a coding block or atransform block may be determined based on whether at least one of awidth or a height of a sub-block generated by partitioning a codingblock or a transform block is smaller than a threshold value. In thiscase, a threshold value may be an integer such as 2, 4, or 8, etc.

FIG. 42 is a diagram for describing a partitioning aspect of a codingblock.

If horizontal directional partitioning is applied to a 4×8 sized codingblock shown in FIG. 42 (a), the coding block is partitioned into 2×8sized sub-blocks. In this case, a width of a sub-block is smaller than athreshold value, so horizontal directional partitioning may beunavailable for the coding block. On the other hand, if verticaldirectional partitioning is applied to a 4×8 sized coding block, thecoding block is partitioned into 4×4 sized sub-blocks. As both a widthand a height of a sub-block are equal to or greater than a thresholdvalue, vertical directional partitioning may be available for the codingblock. As only vertical directional partitioning is available for thecoding block, encoding of information representing a partitioning typefor the coding block may be omitted and vertical directionalpartitioning may be applied to the coding block.

If vertical directional partitioning is applied to an 8×4 sized codingblock shown in FIG. 42 (b), the coding block is partitioned into 8×2sized sub-blocks. In this case, a height of a sub-block is smaller thana threshold value, so vertical directional partitioning may beunavailable for the coding block. On the other hand, if horizontaldirectional partitioning is applied to an 8×4 sized coding block, thecoding block is partitioned into 4×4 sized sub-blocks. As both a widthand a height of a sub-block are equal to or greater than a thresholdvalue, horizontal directional partitioning may be available for thecoding block. As only horizontal directional partitioning is availablefor the coding block, encoding of information representing apartitioning type for the coding block may be omitted and verticaldirectional partitioning may be applied to the coding block.

If both vertical directional partitioning and horizontal directionalpartitioning are available, a partitioning type of a coding block may bedetermined by parsing information indicating a partitioning type of acoding block.

The number of sub-blocks may be determined based on at least one of asize or a shape of a coding block or a transform block. In an example,when one of a width or a height of a coding block is 8 and the other is4, a coding block may be partitioned into 2 sub-blocks. On the otherhand, when both a width and a height of a coding block is 8 or more orwhen one of a width or a height of a coding block is greater than 8, acoding block may be partitioned into 4 sub-blocks. In summary, when acoding block has a 4×4 size, a coding block may not be partitioned intosub-blocks. When a coding block has a 4×8 or 8×4 size, a coding blockmay be partitioned into 2 sub-blocks. Otherwise, a coding block may bepartitioned into 4 sub-blocks.

Alternatively, information representing a size or a shape of a sub-blockor the number of sub-blocks may be signaled in a bitstream. A size or ashape of sub-blocks may be determined by information representing thenumber of sub-blocks. Alternatively, the number of sub-blocks may bedetermined by information representing a size or a shape of sub-blocks.

When a sub-partition intra encoding method is applied, sub-blocksgenerated by partitioning a coding block or a transform block may usethe same intra-prediction mode. In an example, MPMs for a coding blockmay be derived based on an intra-prediction mode of neighboring blocksadjacent to a coding block and an intra-prediction mode for a codingblock may be determined based on derived MPMs. When an intra-predictionmode of a coding block is determined, each sub-block may performintra-prediction by using a determined intra-prediction mode.

When a sub-partition intra encoding method is applied, one of MPMs maybe determined as an intra-prediction mode of a coding block. In otherwords, when a sub-partition intra encoding method is applied, an MPMflag may be inferred to be true although the MPM flag is not signaled.

Alternatively, when a sub-partition intra encoding method is applied,one of predefined candidate intra-prediction modes may be determined asan intra-prediction mode of a coding block. In an example, one of anintra-prediction mode has a horizontal direction, an intra-predictionmode has a vertical direction, an intra-prediction mode has a diagonaldirection (e.g., at least one of a top-left intra-prediction mode, atop-right intra-prediction mode or a bottom-left intra-prediction mode)or a non-directional intra-prediction mode (e.g., at least one of aplanar or a DC) may be determined as an intra-prediction mode of acoding block. Index information specifying one of pre-defined candidateintra-prediction modes may be signaled in a bitstream. Alternatively,according to a partitioning direction of a coding block, the numberand/or type of candidate intra-prediction modes may be different. In anexample, when horizontal directional partitioning is applied to a codingblock, at least one of a non-directional intra-prediction mode, anintra-prediction mode has a vertical direction, an intra-prediction modehas a top-left diagonal direction or an intra-prediction mode has atop-right diagonal direction may be set as a candidate intra-predictionmode. On the other hand, when vertical directional partitioning isapplied to a coding block, at least one of a non-directionalintra-prediction mode, an intra-prediction mode has a horizontaldirection, an intra-prediction mode has a top-left diagonal direction oran intra-prediction mode has a bottom-left diagonal direction may be setas a candidate intra-prediction mode.

According to an embodiment of the present disclosure, at least oneintra-prediction mode of sub-blocks may be set differently from othersub-blocks. In an example, an intra-prediction mode of the N-thsub-block may be derived by adding or subtracting an offset to or froman intra-prediction mode of the (N−1)-th sub-block. An offset may bepredefined in an encoding device and a decoding device. Alternatively,an offset may be derived based on at least one of a size, a shape or anintra-prediction mode of a coding block, a size or a shape of asub-block, the number of sub-blocks or a partitioning direction of acoding block. Alternatively, information for deriving an offset may besignaled in a bitstream.

Alternatively, when an intra-prediction mode of the (N−1)-th sub-blockis a non-directional mode, an intra-prediction mode of the N-thsub-block may be also set the same as an intra-prediction mode of the(N−1)-th sub-block, and when an intra-prediction mode of the (N−1)-thsub-block is a directional mode, an intra-prediction mode derived byadding or subtracting an offset to or from an intra-prediction mode ofthe (N−1)-th sub-block may be set as an intra-prediction mode of theN-th sub-block.

Alternatively, a directional intra-prediction mode may be applied topart of a plurality of sub-blocks and a non-directional intra-predictionmode may be applied to the rest. A sub-block to which a non-directionalintra-prediction mode is applied may be determined by considering atleast one of a size, a shape or a position of a sub-block or the numberof sub-blocks. Alternatively, only when a directional intra-predictionmode applied to one of a plurality of sub-blocks is a predefined value,a non-directional intra-prediction mode may be applied to another.

Alternatively, an intra-prediction mode of each sub-block may be derivedfrom MPMs. For it, index information specifying any one of MPMs may besignaled for each sub-block.

Alternatively, an intra-prediction mode of each sub-block may be derivedfrom predefined candidate intra-prediction modes. For it, indexinformation specifying any one of predefined candidate intra-predictionmodes may be signaled for each sub-block. The number and/or type ofcandidate intra-prediction modes may be set differently per sub-block.

Alternatively, information representing whether an intra-prediction modeof sub-blocks is set the same may be signaled in a bitstream.

A quantization parameter of sub-blocks may be individually determined.Accordingly, a value of a quantization parameter of each sub-block maybe set differently. Information representing a difference value with aquantization parameter of a previous sub-block may be encoded todetermine a quantization parameter of each sub-block. In an example, forthe N-th sub-block, a different value between a quantization parameterof the N-th sub-block and a quantization parameter of the (N−1)-thsub-block may be encoded.

Intra-prediction of a sub-block may be performed by using a referencesample. In this case, a reference sample may be derived from areconstructed sample of a neighboring block adjacent to a sub-block.When a neighboring block adjacent to a sub-block is another sub-blockincluded in the same coding block as the sub-block, a reference sampleof the sub-block may be derived based on a reconstructed sample of theother sub-block. In an example, when the first sub-block is positionedat the left or the top of the second sub-block, a reference sample ofthe second sub-block may be derived from a reconstructed sample of thefirst sub-block. For it, parallel intra-prediction may not be appliedbetween sub-blocks. In other words, encoding/decoding may proceedsequentially for sub-blocks included in a coding block. Accordingly,after encoding/decoding of the first sub-block is completed,intra-prediction for the second sub-block may be performed.

When a sub-partition intra encoding method is applied, it may be set notto use a multi-line intra-prediction encoding method selecting any oneof a plurality of reference sample line candidates. When a multi-lineintra-prediction encoding method is not used, an adjacent referencesample line adjacent to each sub-block may be determined as a referencesample line of each sub-block. Alternatively, when an index of areference sample line of a current block is greater than 0, encoding ofa syntax element, intra_subpartitions_mode_flag, representing whether asub-partition intra encoding method is applied, may be omitted. Whenencoding of a syntax, intra_subpartitions_mode_flag, is omitted, asub-partition intra encoding method may not be applied.

Alternatively, although a sub-partition intra encoding method isapplied, a multi-line intra-prediction encoding method may be used. Forit, index information for specifying a reference sample line may besignaled for each sub-block. Alternatively, index information forspecifying a reference sample line may be signaled only for any one of aplurality of sub-blocks and the index information may also be applied toremaining sub-blocks. Alternatively, index information for specifying areference sample line may be signaled for a coding block and a pluralityof sub-blocks included in the coding block may share the indexinformation.

Alternatively, a multi-line intra-prediction encoding method may be usedonly for a sub-block at a pre-defined position or a sub-block having apredefined partition index among sub-blocks. In an example, indexinformation specifying any one of reference sample line candidates maybe signaled only for a sub-block whose partition index is 0 or asub-block adjoining a top boundary or a left boundary of a coding blockamong a plurality of sub-blocks. A multi-line intra-prediction encodingmethod may not be applied to remaining sub-blocks. Accordingly,remaining sub-blocks may perform intra-prediction by using an adjacentreference sample line.

When a prediction block is generated as a result of intra-prediction,prediction samples may be updated based on each position of predictionsamples included in a prediction block. Such an update method may bereferred to as a sample position-based intra weighting prediction method(or, Position Dependent Prediction Combination, PDPC).

Whether PDPC is used may be determined considering a size, a shape or anintra-prediction mode of a current block, a reference sample line of acurrent block, a size of a current block or a color component. In anexample, PDPC may be used when the intra-prediction mode of a currentblock is at least one of a planar, DC, a vertical direction, ahorizontal direction, a mode with an index value smaller than a verticaldirection or a mode with an index value larger than a horizontaldirection. Alternatively, PDPC may be used only when at least one of awidth or height of a current block is greater than 4. Alternatively,PDPC may be used only when the index of a reference picture line of acurrent block is 0. Alternatively, PDPC may be used only when the indexof a reference picture line of a current block is over the predefinedvalue. Alternatively, PDPC may be used only for a luminance component.Alternatively, Whether PDPC is used may be determined according towhether more than 2 of the above-enumerated conditions are satisfied.

Alternatively, based on whether a sub-partition intra encoding method isused or not, whether PDPC is used or not may be determined. In anexample, when a sub-partition intra encoding method is applied to acoding block or a transform block, PDPC may be set not to be used.Alternatively, when a sub-partition intra encoding method is applied toa coding block or a transform block, PDPC may be applied to at least oneof a plurality of sub-blocks. In this case, a sub-block which is atarget of PDPC may be determined based on at least one of a size, ashape, a position, an intra-prediction mode or a reference sample lineindex of a coding block or a sub-block. In an example, PDPC may beapplied to a sub-block adjacent to the top and/or left boundary of acoding block, or a sub-block adjacent to the bottom and/or rightboundary of a coding block. Alternatively, based on a size or a shape ofa sub-block, it may be set to apply PDPC to all sub-blocks included in acoding block, or not to apply PDPC to all sub-blocks included in acoding block. In an example, when at least one of a width or a height ofa sub-block is smaller than a threshold value, application of PDPC maybe omitted. In another example, PDPC may be applied to all sub-blocks ina coding block.

Alternatively, based on whether at least one of a size, a shape, anintra-prediction mode or a reference picture index of sub-blocksgenerated by partitioning a coding block or a transform block satisfiesa preset condition or not, whether PDPC is applied or not may bedetermined for each sub-block. In an example, when at least one of awidth or a height of a sub-block is greater than 4, PDPC may be appliedto a sub-block.

In another example, information showing whether PDPC is applied may besignaled in a bitstream.

Alternatively, based on at least one of a size, a shape or anintra-prediction mode of a current block or a position of a predictionsample, a region to which PDPC is applied may be determined. In anexample, when an intra-prediction mode of a current block has an indexgreater than a vertical direction, a prediction sample that at least oneof an x-axis coordinate or a y-axis coordinate is greater than athreshold value may not be corrected and only a prediction sample thatan x-axis coordinate or a y-axis coordinate is equal to or less than athreshold value may be corrected. Alternatively, when anintra-prediction mode of a current block has an index smaller than ahorizontal direction, a prediction sample that at least one of an x-axiscoordinate or a y-axis coordinate is greater than a threshold value maynot be corrected and only a prediction sample that an x-axis coordinateor a y-axis coordinate is equal to or less than a threshold value may becorrected. In this case, a threshold value may be determined based on atleast one of a size, a shape or an intra-prediction mode of a currentblock.

When a prediction sample is obtained through an intra-prediction sample,a reference sample used to correct the prediction sample may bedetermined based on the position of the obtained prediction sample.

A residual image may be derived by subtracting a prediction image froman original image. In this connection, when the residual image isconverted into a frequency domain, even though high frequency componentsare removed from frequency components, subjective image quality of theimage does not drop significantly. Accordingly, when values of highfrequency components are transformed into small values, or when valuesof high frequency components are set to 0, compression efficiency may beincreased without causing large visual distortion. Reflecting the abovefeature, transform may be performed on a current block so as todecompose a residual image to two-dimensional frequency components. Thetransform may be performed by using transform methods such as DCT(discrete cosine transform), DST (discrete sine transform), etc.

DCT is to decompose (or transform) a residual image into atwo-dimensional frequency component by using cosine transform and DST isto compose (or transform) a residual image into a two-dimensionalfrequency component by using sine transform. As a result of transforminga residual image, frequency components may be represented as a baseimage. In an example, when DCT transform is performed for a N×N sizedblock, N2 basic pattern components may be obtained. A size of each ofbasic pattern components included in a N×N sized block may be obtainedthrough transform. According to a used transform method, a size of abasic pattern component may be referred to as a DCT coefficient or a DSTcoefficient.

A transform method DCT is mainly used to transform an image that a lotof non-zero low frequency components are distributed. A transform methodDST is mainly used for an image that a lot of high frequency componentsare distributed.

It is also possible to transform a residual image by using a transformmethod other than DCT or DST.

Hereinafter, transforming a residual image into two-dimensionalfrequency components is referred to as two-dimensional image transform.In addition, a size of basic pattern components obtained by transform isreferred to as a transform coefficient. In an example, a transformcoefficient may mean a DCT coefficient or a DST coefficient. When boththe after-described first transform and second transform are applied, atransform coefficient may mean a basic pattern component generated by aresult of the second transform. In addition, a residual sample to whichtransform skip is applied is also referred to as a transformcoefficient.

A transform method may be determined in a unit of a block. A transformmethod may be determined based on at least one of a prediction encodingmode of a current block, a size of a current block or a shape of acurrent block. In an example, when a current block is encoded by anintra-prediction mode and a size of a current block is smaller than N×N,transform may be performed by using a DST transform method. On the otherhand, when the condition is not satisfied, transform may be performed byusing a DCT transform method.

Two-dimensional image transform may not be performed for some blocks ofa residual image. Not performing two-dimensional image transform may bereferred to as transform skip. The transform skip represents that thefirst transform and the second transform are not applied to the currentblock. When transform skip is applied, quantization may be applied toresidual values for which transform is not performed.

Whether transform skip is allowed for a current block may be determinedbased on at least one of a size or a shape of a current block. In anexample, only when a size of a current block is smaller than a thresholdvalue, transform skip may be applied. The threshold value is related toat least one of a width, a height or the number of samples of a currentblock, and may be defined as 32×32, etc. Alternatively, transform skipmay be allowed only for a square block. In an example, transform skipmay be allowed for a 32×32, 16×16, 8×8 or 4×4 sized square block.Alternatively, only when a sub-partition intra encoding method is notused, transform skip may be allowed.

Alternatively, when a sub-partition intra encoding method is applied toa current block, it may be determined for each sub-block whether toapply transform skip.

FIG. 43 is a diagram showing an example in which whether transform skipis performed or not is determined per sub-block.

Transform skip may be applied only for part of a plurality ofsub-blocks. In an example, as in an example shown in FIG. 43, it may beset to apply transform skip to a sub-block at a top position of acurrent block and not to apply transform skip for a sub-block at abottom position.

A transform type of a sub-block that transform skip is not allowed maybe determined based on information signaled in a bitstream. In anexample, a transform type may be determined based on tu_mts_idx whichwill be described after.

Alternatively, a transform type of a sub-block may be determined basedon a size of a sub-block. In an example, a horizontal directionaltransform type may be determined based on whether a width of a sub-blockis equal to or greater than and/or equal to or less than a thresholdvalue, and a vertical directional transform type may be determined basedon whether a height of a sub-block is equal to or greater than and/orequal to or less than a threshold value.

After performing transform on a current block by using DCT or DST,transform may be performed again on the transformed current block. Inthis connection, transform based on DCT or DST may be defined as firsttransform, and performing transform again on a block to which firsttransform is applied may be defined as second transform.

First transform may be performed by using any one of a plurality oftransform core candidates. In an example, first transform may beperformed by using any one of DCT2, DCT8, or DST7.

Different transform cores may be used for a horizontal direction and avertical direction. Information representing a combination of atransform core of a horizontal direction and a transform core of avertical direction may be signaled in a bitstream.

A processing unit of first transform may differ with second transform.In an example, first transform may be performed on an 8×8 block, andsecond transform may be performed on a 4×4 sized sub-block within thetransformed 8×8 block. Alternatively, the second transform may beperformed for transform coefficients which belong to 3 4×4 sizedsub-blocks. The 3 sub-blocks may include a sub-block positioned at thetop-left of a current block, a sub-block neighboring the right of thesub-block and a sub-block neighboring the bottom of the sub-block.Alternatively, the second transform may be performed for a 8×8 sizedblock.

It is also possible that transform coefficients in a remaining region onwhich the second transform is not performed may be set to 0.

Alternatively, first transform may be performed on a 4×4 block, andsecond transform may be performed on a region having an 8×8 sizeincluding the transformed 4×4 block.

Information representing whether or not to perform second transform maybe signaled in a bitstream. In an example, a flag representing whetherthe second transform is performed or not, or index informationspecifying whether the second transform is performed or not and atransform kernel used for the second transform may be signaled. In anexample, when the index information is 0, it represents that the secondtransform is not performed for a current block. On the other hand, whenthe index information is greater than 0, a transform kernel for thesecond transform may be determined by the index information.

Alternatively, whether to perform the second transform may be determinedbased on whether a horizontal directional transform core and a verticaldirectional transform core are identical with each other. In oneexample, the second transform may be performed only when the horizontaldirectional transform core and the vertical directional transform coreare identical with each other. Alternatively, the second transform maybe performed only when the horizontal directional transform core and thevertical directional transform core are different from each other.

Alternatively, the second transform may be allowed only when apredefined transform core is used for the horizontal directionaltransform and the vertical directional transform. In one example, when aDCT2 transform core is used for transform in the horizontal directionand transform in the vertical direction, the second transform may beallowed. Alternatively, when a sub-partition intra encoding method isapplied to a current block, the second transform may be allowed onlywhen a DCT2 transform core is used for transform in a horizontaldirection and transform in a vertical direction.

Alternatively, it may be determined whether to perform the secondtransform based on the number of non-zero transform coefficients of thecurrent block. In one example, when the number of the non-zerotransforms coefficient of the current block is smaller than or equal toa threshold, the prediction method may be configured not to use thesecond transform. When the number of the non-zero transform coefficientsof the current block is greater than the threshold, the predictionmethod may be configured to use the second transform. As long as thecurrent block is encoded using intra prediction, the prediction methodmay be configured to use the second transform.

Alternatively, whether the second transform is performed or not may bedetermined based on a position of the last non-zero transformcoefficient of a current block. In an example, when at least one of anx-axis coordinate or a y-axis coordinate of the last non-zero transformcoefficient of a current block is greater than a threshold value, orwhen at least one of an x-axis coordinate or a y-axis coordinate of asub-block to which the last non-zero transform coefficient of a currentblock belongs is greater than a threshold value, the second transformmay not be performed. In this case, a threshold value may be predefinedin an encoding device and a decoding device. Alternatively, a thresholdvalue may be determined based on a size or a shape of a current block.

Alternatively, when only a transform coefficient of a DC componentexists in a current block, it may be set not to perform the secondtransform. In this case, a DC component represents a transformcoefficient at a top-left position in a current block.

Alternatively, when matrix-based intra-prediction is applied to acurrent block, it may be set not to perform the second transform.

Information representing a transform type of a current block may besignaled in a bitstream. The information may be index information,tu_mts_idx, representing one of combinations of a transform type for ahorizontal direction and a transform type for a vertical direction.

Based on transform type candidates specified by index information,tu_mts_idx, a transform core for a vertical direction and a transformcore for a horizontal direction may be determined. Table 9 representstransform type combinations according to tu_mts_idx.

TABLE 9 transform type tu_mts_idx horizontal vertical 0 DCT-II DCT-II 1DST-VII DST-VII 2 DCT-VIII DST-VII 3 DST-VII DCT-VIII 4 DCT-VIIIDCT-VIII

A transform type may be determined as one of DCT2, DST7 or DCT8.Alternatively, transform skip may be inserted in a transform typecandidate.

When Table 9 is used, DCT2 may be applied in a horizontal direction andin a vertical direction when tu_mts_idx is 0. When tu_mts_idx is 2, DCT8may be applied in a horizontal direction and DCT7 may be applied in avertical direction.

When a sub-partition intra encoding method is applied, a transform coreof a sub-block may be independently determined. In an example,information for specifying a transform type combination candidate may beencoded and signaled per sub-block. Accordingly, a transform corebetween sub-blocks may be different.

Alternatively, sub-blocks may use the same transform type. In this case,tu_mts_idx specifying a transform type combination candidate may besignaled only for the first sub-block. Alternatively, tu_mts_idx may besignaled in a coding block level and a transform type of sub-blocks maybe determined by referring to tu_mts_idx signaled in a coding blocklevel. Alternatively, a transform type may be determined based on atleast one of a size, a shape or an intra-prediction mode of one amongsub-blocks and a determined transform type may be set to be used for allsub-blocks.

FIG. 44 is a diagram showing an example in which sub-blocks use the sametransform type.

When a coding block is partitioned in a horizontal direction, atransform type of a sub-block at a top position of a coding block(Sub-CU0) may be set the same as that of a sub-block at a bottomposition (Sub-CU1). In an example, as in an example shown in FIG. 44(a), when a horizontal transform type and a vertical transform type aredetermined based on tu_mts_idx signaled for a top sub-block, adetermined transform type may be also applied to a bottom sub-block.

When a coding block is partitioned in a vertical direction, a transformtype of a sub-block at a left position of a coding block (Sub-CU0) maybe set the same as that of a sub-block at a right position (Sub-CU1). Inan example, as in an example shown in FIG. 44 (b), when a horizontaltransform type and a vertical transform type are determined based ontu_mts_idx signaled for a left sub-block, a determined transform typemay be also applied to a right sub-block.

Whether index information is encoded or not may be determined based onat least one of a size or a shape of a current block, the number ofnon-zero coefficients, whether the second transform is performed orwhether a sub-partition intra encoding method is applied. In an example,when a sub-partition intra encoding method is applied to a currentblock, or when the number of non-zero coefficients is equal to orsmaller than a threshold value, signaling of index information may beomitted. When signaling of index information is omitted, a defaulttransform type may be applied to a current block.

A default transform type may include at least one of DCT2 or DST7. Whenthere are a plurality of default transform types, one of a plurality ofdefault transform types may be selected by considering at least one of asize, a shape or an intra-prediction mode of a current block, whetherthe second transform is performed or whether a sub-partition intraencoding method is applied. In an example, one of a plurality oftransform types may be determined as a horizontal directional transformtype based on whether a width of a current block is in a preset range,and one of a plurality of transform types may be determined as avertical directional transform type based on whether a height of acurrent block is in a preset range. Alternatively, a default mode may bedetermined differently according to a size, a shape or anintra-prediction mode of a current block or whether the second transformis performed.

Alternatively, when only a transform coefficient of a DC componentexists in a current block, a horizontal directional transform type and avertical directional transform type may be set as a default transformtype. In an example, when only a transform coefficient of a DC componentexists in a current block, a horizontal directional transform type and avertical directional transform type may be set as DCT2.

A threshold value may be determined based on a size or a shape of acurrent block. In an example, when a size of a current block is equal toor smaller than 32×32, a threshold value may be set to be 2, and when acurrent block is greater than 32×32 (e.g., when a current block is a32×64 or 64×32 sized coding block), a threshold value may be set to be4.

A plurality of look-up tables may be prestored in an encoding device/adecoding device. At least one of an index value assigned to transformtype combination candidates, a type of transform type combinationcandidates or the number of transform type combination candidates may bedifferent for each of the plurality of look-up tables.

Based on at least one of a size, a shape or an intra-prediction mode ofa current block, whether the second transform is applied or not, orwhether transform skip is applied to a neighboring block, a look-uptable for a current block may be selected.

In an example, when a size of a current block is equal to or less than4×4, or when a current block is encoded by inter-prediction, a firstlook-up table may be used and when a size of a current block is greaterthan 4×4, or when a current block is encoded by intra-prediction, asecond look-up table may be used.

Alternatively, information indicating one of a plurality of look-uptables may be signaled in a bitstream. A decoding device may select alook-up table for a current block based on the information.

In another example, an index assigned to a transform type combinationcandidate may be adaptively determined based on at least one of a size,a shape, a prediction encoding mode or an intra-prediction mode of acurrent block, whether the second transform is applied or not, orwhether transform skip is applied to a neighboring block. In an example,an index assigned to transform skip when a size of a current block is4×4 may be smaller than an index assigned to transform skip when a sizeof a current block is greater than 4×4. Concretely, when a size of acurrent block is 4×4, an index 0 may be assigned to transform skip andwhen a current block is greater than 4×4 and equal to or less than16×16, an index greater than 0 (e.g., an index 1) may be assigned totransform skip. When a current block is greater than 16×16, the maximumvalue (e.g., 5) may be assigned to an index of transform skip.

Alternatively, when a current block is encoded by inter-prediction, anindex 0 may be assigned to transform skip. When a current block isencoded by intra-prediction, an index greater than 0 (e.g., an index 1)may be assigned to transform skip.

Alternatively, when a current block is a 4×4 sized block encoded byinter-prediction, an index 0 may be assigned to transform skip. On theother hand, when a current block is not encoded by inter-prediction, orwhen a current block is greater than 4×4, an index greater than 0 (e.g.,an index 1) may be assigned to transform skip.

It is also possible to use transform type combination candidatesdifferent from transform type combination candidates enumerated in Table9. In an example, a transform type combination candidate which isconsisted of transform skip applied to one of a horizontal directionaltransform or a vertical directional transform and a transform core suchas DCT2, DCT8 or DST7, etc. applied to the other can be used. In thiscase, whether transform skip will be used as a transform type candidatefor a horizontal direction or a vertical direction may be determinedbased on at least one of a size (e.g., a width and/or a height), ashape, a prediction encoding mode or an intra-prediction mode of acurrent block.

Information representing whether index information for determining atransform type of a current block is explicitly signaled may be signaledin a bitstream. In an example, sps_explicit_intra_mts_flag, informationrepresenting whether an explicit transform type determination is allowedfor a block encoded by intra-prediction, and/orsps_explicit_inter_mts_flag, information representing whether anexplicit transform type determination is allowed for a block encoded byinter-prediction, may be signaled at a sequence level.

When an explicit transform type determination is allowed, a transformtype of a current block may be determined based on index information,tu_mts_idx, signaled in a bitstream. On the other hand, when an explicittransform type determination is not allowed, a transform type may bedetermined based on at least one of a size or a shape of a currentblock, whether it is allowed to perform transform in a unit of asub-block, a position of a sub-block including a non-zero transformcoefficient, whether the second transform is performed or not, orwhether a sub-partition intra encoding method is applied or not. In anexample, a horizontal directional transform type of a current block maybe determined based on a width of a current block and a verticaldirectional transform type of a current block may be determined based ona height of a current block. For example, when a width of a currentblock is smaller than 4 or greater than 16, a horizontal directionaltransform type may be determined as DCT2. Otherwise, a horizontaldirectional transform type may be determined as DST7. When a height of acurrent block is smaller than 4 or greater than 16, a verticaldirectional transform type may be determined as DCT2. Otherwise, avertical directional transform type may be determined as DST7. In thiscase, a threshold value which is to be compared with a width and aheight may be determined based on at least one of a size, a shape or anintra-prediction mode of a current block to determine a horizontaldirectional transform type and a vertical directional transform type.

Alternatively, when a current block has a square shape whose height andwidth are the same, a horizontal directional transform type and avertical directional transform type may be set the same, but when acurrent block has a non-square shape whose height and width aredifferent from each other, a horizontal directional transform type and avertical directional transform type may be set differently. In anexample, when a width of a current block is greater than a height, ahorizontal directional transform type may be determined as DST7 and avertical directional transform type may be determined as DCT2. When aheight of a current block is greater than a width, a verticaldirectional transform type may be determined as DST7 and a horizontaldirectional transform type may be determined as DCT2.

The number and/or type of transform type candidates or the number and/ortype of transform type combination candidates may be different accordingto whether an explicit transform type determination is allowed or not.In an example, when an explicit transform type determination is allowed,DCT2, DST7 and DCT8 may be used as transform type candidates.Accordingly, each of a horizontal directional transform type and avertical directional transform type may be set as DCT2, DST8 or DCT8.When an explicit transform type determination is not allowed, only DCT2and DST7 may be used as a transform type candidate. Accordingly, each ofa horizontal directional transform type and a vertical directionaltransform type may be determined as DCT2 or DST7.

A coding block or a transform block may be partitioned into a pluralityof sub-blocks and transform may be performed only for part of aplurality of sub-blocks. Applying transform to only part of a pluralityof sub-blocks may be defined as a sub-transform block encoding method.

FIGS. 45 and 46 are diagrams showing an application aspect of asub-transform block encoding method.

FIG. 45 is a diagram showing an example in which transform is performedonly for one of 4 sub-blocks and FIG. 50 is a diagram showing an examplein which transform is performed only for any one of 2 sub-blocks. InFIGS. 45 and 46, it is assumed that transform is performed only for asub-block on which ‘Target’ is marked.

As in an example shown in FIG. 45, after a coding block is partitionedinto 4 sub-blocks by using a vertical line and a horizontal line whichare mutually orthogonal, transform and quantization may be performedonly for one of them. Transform coefficients in a sub-block on whichtransform is not performed may be set to 0.

Alternatively, as in an example shown in FIG. 46, after a coding blockis partitioned into 2 sub-blocks by using a vertical line or ahorizontal line, transform and quantization may be performed only forone of them. Transform coefficients in a sub-block on which transform isnot performed may be set to 0.

Information representing whether a sub-transform block encoding methodis applied to a coding block may be signaled in a bitstream. Theinformation may be a 1-bit flag, cu_sbt_flag. When the flag is 1, itrepresents that transform is performed only for part of a plurality ofsub-blocks generated by partitioning a coding block or a transformblock, and when the flag is 0, it represents that transform is performedwithout partitioning a coding block or a transform block intosub-blocks.

Whether a sub-transform block encoding method may be used for a codingblock may be determined based on at least one of a size, a shape or aprediction encoding mode of a coding block, or whether a combinedprediction mode is used for a coding block. In an example, when at leastone of a case in which at least one of a width or a height of a codingblock is equal to or greater than a threshold value, a case in whichinter-prediction is applied to a coding block, or a case in which acombined prediction mode is not applied to a coding block is satisfied,a sub-transform block encoding method may be available for a codingblock. In this case, a threshold value may be a natural number such as4, 8, or 16, etc.

Alternatively, when a ration between a width and a height of the codingblock is greater than a threshold value, it may not be allowed to applythe sub-transform block encoding method.

When intra-prediction is applied to a coding block or when an intrablock copy mode is applied, a sub-transform block encoding method may bedetermined to be unavailable.

Alternatively, whether a sub-transform block encoding method isavailable for a coding block may be determined based on whether asub-partition intra encoding method is applied to a coding block. In anexample, when a sub-partition intra encoding method is applied, asub-transform block encoding method may be determined to be available.

When a sub-transform block encoding method is determined to be availablefor a coding block, a syntax, cu_sbt_flag, may be signaled in abitstream. According to a value of parsed cu_sbt_flag, whether asub-transform block encoding method is applied may be determined.

On the other hand, when a sub-transform block encoding method isdetermined to be unavailable for a coding block, signaling of a syntax,cu_sbt_flag, may be omitted. When signaling of a syntax, cu_sbt_flag, isomitted, it may be determined not to apply a sub-transform blockencoding method to a coding block.

When a sub-transform encoding method is applied to a coding block,information representing a partitioning shape of a coding block may besignaled in a bitstream. Information representing a partitioning shapeof a coding block may include at least one of information representingwhether a coding block is partitioned into 4 sub-blocks, informationrepresenting a partitioning direction of a coding block or informationrepresenting the number of sub-blocks.

In an example, when a syntax, cu_sbt_flag, is 1, a flag,cu_sbt_quadtree_flag, representing whether a coding block is partitionedinto 4 sub-blocks may be signaled. When a syntax, cu_sbt_quadtree_flag,is 1, it represents that a coding block is partitioned into 4sub-blocks. In an example, a coding block may be partitioned into 4sub-blocks by using 3 vertical lines or 3 horizontal lines, or a codingblock may be partitioned into 4 sub-blocks by using 1 vertical line and1 horizontal line. Partitioning a coding block into 4 sub-blocks may bereferred to as quad tree partitioning.

When a syntax, cu_sbt_quadtree_flag, is 0, it represents that a codingblock is partitioned into 2 sub-blocks. In an example, a coding blockmay be partitioned into 2 sub-blocks by using 1 vertical line or 1horizontal line. Partitioning a coding block into 2 sub-blocks may bereferred to as binary tree partitioning. When a value of the syntaxcu_sbt_quad_tree_flag is 0, a sub-block whose a size is ½ of the codingblock may be included in the coding block.

In addition, a flag representing a partitioning direction of a codingblock may be signaled in a bitstream. In an example, a flag,cu_sbt_horizontal_flag, representing whether horizontal directionalpartitioning is applied to a coding block may be encoded and signaled.When a value of cu_sbt_horizontal_flag is 1, it represents thathorizontal directional partitioning using at least one partitioning lineparallel to a top side and a bottom side of a coding block is applied.When a value of cu_sbt_horizontal_flag is 0, it represents that verticaldirectional partitioning using at least one partitioning line parallelto a left side and a right side of a coding block is applied.

According to a size or a shape of a coding block, a partitioning shapeof a coding block may be determined. In an example, quad treepartitioning may be available when at least one of a width or a heightof a coding block is equal to or greater than the first threshold value.In an example, the first threshold value may be a natural number such as4, 8, or 16. The first threshold value may be referred to as a quad treethreshold value.

When quad tree partitioning is determined to be available, a syntax,cu_sbt_quadtree_flag, may be signaled in a bitstream. According to avalue of parsed cu_sbt_quadtree_flag, whether quad tree partitioning isapplied to a coding block may be determined.

When quad tree partitioning is determined to be unavailable, signalingof a syntax, cu_sbt_quadtree_flag, may be omitted. When signaling of asyntax, cu_sbt_quadtree_flag, is omitted, it may be determined to applybinary tree partitioning to a coding block.

Table 10 illustrates a syntax structure for determining whether asyntax, cu_sbt_quadtree_flag, is parsed.

TABLE 10 Descriptor coding_unit( x0, y0, cbWidth, cbHeight, treeType ) {... if( !pcm_flag[ x0 ][ y0 ] ) { if( CuPredMode[ x0 ][ y0 ] !=MODE_INTRA && merge_flag[ x0 ][ y0 ] = = 0 ) cu_cbf ae(v) if( cu_cbf ) {if( CuPredMode[ x0 ][ y0 ] = = MODE_INTER && sps_sbt_enabled_flag &&!ciip_flag[ x0 ][ y0 ] ) { if( cbWidth <= MaxSbtSize && cbHeight <=MaxSbtSize ) { allowSbtVerH = cbWidth >= 8 allowSbtVerQ = cbWidth >= 16allowSbtHorH = cbHeight >= 8 allowSbtHorQ = cbHeight >= 16 if(allowSbtVerH | | allowSbtHorH | | allowSbtVerQ | | allowSbtHorQ )cu_sbt_flag ae(v) } if( cu_sbt_flag ) { if( ( allowSbtVerH | |allowSbtHorH ) &&  ( allowSbtVerQ && allowSbtHorQ) ) cu_sbt_quad_flagae(v) if( ( cu_sbt_quad_flag && allowSbtVerQ && allowSbtHorQ ) | | (!cu_sbt_quad_flag && allowSbtVerH && allowSbtHorH ) )cu_sbt_horizontal_flag ae(v) cu_sbt_pos_flag ae(v) } } transform_tree(x0, y0, cbWidth, cbHeight, treeType ) } } }

In Table 10, a variable, allowSbtVerQ, represents whether quad treepartitioning in a vertical direction is allowed and a variable,allowSbtHorQ, represents whether quad tree partitioning in a horizontaldirection is allowed. Variables, allowSbtVerQ and allowSbtHorQ, may bedetermined based on a quad tree threshold value. In an example, when aquad tree threshold value is 16, allowSbtVerQ may be determined based onwhether a width of a coding block is equal to or greater than 16, andallowSbtHorQ may be determined based on whether a height of a codingblock is equal to or greater than 16.

As in an example shown in Table 10, when all variables, allowSbtVerQ andallowSbtHorQ, are true, a syntax, cu_sbt_quad_flag, may be parsed from abitstream. In an example, when a coding block is 16×8, a variable,allowSbtHorQ, is set to false, so parsing of a syntax, cu_sbt_quad_flag,may be omitted. Alternatively, when a coding block is 8×16, a variable,allowSbtVerQ, is set to false, so parsing of a syntax, cu_sbt_quad_flag,may be omitted. When parsing of a syntax, cu_sbt_quad_flag, is omitted,binary tree partitioning may be applied to a coding block.

Alternatively, unlike an example shown in Table 10, when any one of avariable, allowSbtVerQ, or a variable, allowSbtHorQ, is true, a syntax,cu_sbt_quad_flag, may be parsed. In other words, when only any one of awidth and a height of a coding block is equal to or greater than a quadtree threshold value, quad tree partitioning may be available.

Alternatively, although any one of a width or a height of a coding blockis equal to or greater than the first threshold value, quad treepartitioning of a coding block may be determined to be unavailable whenthe other of a width or a height of a coding block is equal to or lessthan the second threshold value. In this case, the second thresholdvalue may have a value smaller than the first threshold value. In anexample, the second threshold value may be a natural number such as 2,4, or 8.

A variable, allowSbtHorH, represents whether binary tree partitioning ina horizontal direction is available. Binary tree partitioning in ahorizontal direction may be set to be available when a height of acoding block is equal to or greater than a threshold value. A variable,allowSbtVerH, represents whether binary tree partitioning in a verticaldirection is available. Binary tree partitioning in a vertical directionmay be set to be available when a width of a coding block is equal to orgreater than a threshold value. In this case, a threshold value may be anatural number such as 4, 8, or 16.

When both quad/binary tree partitioning in a horizontal direction andquad/binary tree partitioning in a vertical direction are available, asyntax, cu_sbt_horizontal_flag, may be signaled in a bitstream.According to a value of a syntax, cu_sbt_horizontal_flag, partitioningin a horizontal direction or partitioning in a vertical direction may beapplied to a coding block.

On the other hand, when only one of quad/binary tree partitioning in ahorizontal direction and quad/binary tree partitioning in a verticaldirection is available, signaling of a syntax, cu_sbt_horizontal_flag,may be omitted. When signaling of a syntax, cu_sbt_horizontal_flag, isomitted, available one among quad/binary tree partitioning in ahorizontal direction and quad/binary tree partitioning in a verticaldirection can be applied.

Alternatively, a partitioning type of a coding block may be determinedbased on a shape of a coding block. In an example, at least one ofwhether quad tree partitioning is allowed, whether quad/binary treepartitioning in a horizontal direction is allowed or whether quad/binarytree partitioning in a vertical direction is allowed may be determinedbased on whether a width and height ratio of a coding block is greaterthan a threshold value. A threshold value may be a natural number suchas 2, 3, or 4, etc.

Table 11 shows an example in which whether a partitioning type isallowed or not is determined based on a shape of a coding block isdetermined.

TABLE 11 Descriptor coding_unit( x0, y0, cbWidth, cbHeight, treeType ) {... if( !pcm_flag[ x0 ][ y0 ] ) { if( CuPredMode[ x0 ][ y0 ] !=MODE_INTRA && merge_flag[ x0 ][ y0 ] = = 0 ) cu_cbf ae(v) if( cu_cbf ) {if( CuPredMode[ x0 ][ y0 ] = = MODE_INTER && sps_sbt_enabled_flag &&!ciip_flag[ x0 ][ y0 ] ) { if( cbWidth <= MaxSbtSize && cbHeight <=MaxSbtSize ) { allowSbtVerH = cbWidth >= 8 allowSbtVerQ = cbWidth >= 16allowSbtHorH = cbHeight >= 8 allowSbtHorQ = cbHeight >= 16 if (cbWidth >2*cbHeight) allowSbtHorH = false if (cbHeight > 2*cbWidth) allowSbtVerH= false if( allowSbtVerH | | allowSbtHorH | | allowSbtVerQ | |allowSbtHorQ ) cu_sbt_flag ae(v) } if( cu_sbt_flag ) { if( (allowSbtVerH | | allowSbtHorH ) &&  ( allowSbtVerQ && allowSbtHorQ) )cu_sbt_quad_flag ae(v) if( ( cu_sbt_quad_flag && allowSbtVerQ &&allowSbtHorQ ) | | ( !cu_sbt_quad_flag && allowSbtVerH && allowSbtHorH )) cu_sbt_horizontal_flag ae(v) cu_sbt_pos_flag ae(v) } } transform_tree(x0, y0, cbWidth, cbHeight, treeType ) } } }

In Table 11, a variable, allowSbtHorH, represents whether binary treepartitioning in a horizontal direction is allowed and a variable,allowSbtVerH, represents whether binary tree partitioning in a verticaldirection is allowed.

When a width of a coding block is greater than twice a height, avariable, allowSbtHorH, may be set to false. In other words, when awidth of a coding block is greater than twice a height, binary treepartitioning in a horizontal direction may not be allowed.

When a height of a coding block is greater than twice a width, avariable, allowSbtVerH, may be set to false. In other words, when aheight of a coding block is greater than twice a width, binary treepartitioning in a vertical direction may not be allowed.

When binary tree partitioning in a horizontal direction or binary treepartitioning in a vertical direction is unavailable, signaling of asyntax, cu_sbt_horizontal_flag, may be omitted.

When signaling of a syntax, cu_sbt_horizontal_flag, is omitted and avariable, allowSbtHorH, is true, binary tree partitioning in ahorizontal direction may be applied to a coding block.

When signaling of a syntax, cu_sbt_horizontal_flag, is omitted and avariable, allowSbtVerH, is true, binary tree partitioning in a verticaldirection may be applied to a coding block.

Information for specifying a sub-block which is a target of transformamong a plurality of sub-blocks may be signaled in a bitstream. In anexample, a syntax, cu_sbt_pos_flag, may be signaled in a bitstream. Asyntax, cu_sbt_pos_flag, represents whether a transform target is thefirst sub-block in a coding block. In an example, when quad/binary treepartitioning in a horizontal direction is applied to a coding block, aleftmost sub-block is determined as a transform target when cu_sbt_flagis 1, and a rightmost sub-block is determined as a transform target whencu_sbt_flag is 0. When quad/binary tree partitioning in a verticaldirection is applied to a coding block, an uppermost sub-block isdetermined as a transform target when cu_sbt_pos_flag is 1 and a lowestsub-block is determined as a transform target when cu_sbt_pos_flag is 0.

When a coding block is partitioned into 4 sub-blocks whose a height anda width are ½ of the coding block, respectively, an index,cu_sbt_pos_idx, specifying any one of 4 sub-blocks may be signaled,instead of a flag, cu_sbt_pos_flag. A syntax, cu_sbt_pos_idx, may have avalue from 0 to 3 and a sub-block having an index indicated bycu_sbt_pos_idx may be determined as a transform target.

Alternatively, when a coding block is partitioned into sub-blocks, aplurality of sub-blocks may be selected as a transform target. Aplurality of sub-blocks may neighbor to each other in a horizontal orvertical direction.

A transform type of a sub-block may be determined by considering apartitioning direction of a coding block and a position of a sub-block.In an example, when a coding block is partitioned in a verticaldirection and transform is performed for a sub-block at a left positionamong sub-blocks, a horizontal directional transform type and a verticaldirectional transform type may be set differently.

FIGS. 47 and 48 show a horizontal directional transform type and avertical directional transform type according to a position of asub-block which is a target of a transform.

In an example shown in FIG. 47, when a sub-block which is a target of atransform includes a top-left sample or a bottom-right sample of acoding block, a horizontal directional transform type and a verticaldirectional transform type may be set the same. In an example, anexample shown in FIG. 51 illustrated that when a sub-block which is atarget of a transform includes a top-left sample of a coding block, ahorizontal directional transform type and a vertical directionaltransform type are set as DCT8 and when a sub-block which is a target ofa transform includes a bottom-right sample of a coding block, ahorizontal directional transform type and a vertical directionaltransform type are set as DST7.

When a sub-block which is a target of a transform includes a top-rightsample or a bottom-left sample of a coding block, a horizontaldirectional transform type and a vertical directional transform type maybe set differently. In an example, an example shown in FIG. 47illustrated that when a sub-block which is a target of transformincludes a top-right sample of a coding block, a horizontal directionaltransform type is set as DST7 and a vertical directional transform typeis set as DCT8. When a sub-block which is a target of a transformincludes a bottom-left sample of a coding block, a horizontaldirectional transform type is set as DCT8 and a vertical directionaltransform type is set as DST7.

Unlike an example shown in FIG. 47, when a sub-block including atop-left sample or a sub-block including a bottom-right sample in acoding block is determined as a transform target, a horizontaldirectional transform type and a vertical directional transform type maybe set differently and when a sub-block including a top-right sample ora sub-block including a bottom-left sample in a coding block isdetermined as a transform target, a horizontal directional transformtype and a vertical directional transform type may be set the same.

FIG. 47 illustrated that a sub-block whose a height and a width arerespectively ½ of a coding block is set as a transform target. Unlike ina shown example, a sub-block whose a width is the same as a codingblock, but a height is ¼ of a coding block or a sub-block whose a heightis the same as a coding block, but a width is ¼ of a coding block may beset as a transform target.

In an example shown in FIG. 48, when a sub-block which is a target of atransform includes a top-left sample of a coding block, a horizontaldirectional transform type and a vertical directional transform type maybe set differently. In an example, in an example shown in FIG. 48, whenbinary tree partitioning in a horizontal direction is applied and a topsub-block is determined as a transform target, a horizontal directionaltransform type may be set as DST7 and a vertical directional transformtype may be set as DCT7. When binary tree partitioning in a verticaldirection is applied and a left sub-block is determined as a transformtarget, a horizontal directional transform type may be set as DCT8 and avertical directional transform type may be set as DST7.

Unlike an example shown in FIG. 48, when a sub-block which is a targetof a transform includes a top-left sample of a coding block, ahorizontal directional transform type and a vertical directionaltransform type may be set the same, and when a sub-block which is atarget of a transform includes a bottom-right sample of a coding block,a horizontal directional transform type and a vertical directionaltransform type may be set differently.

When a sub-block which is a target of a transform includes abottom-right sample of a coding block, a horizontal directionaltransform type and a vertical directional transform type may be set thesame. In an example, in an example shown in FIG. 48, when binary treepartitioning in a horizontal direction is applied and a bottom sub-blockis determined as a transform target, a horizontal directional transformtype and a vertical directional transform type may be set as DST7. Whenbinary tree partitioning in a vertical direction is applied and a rightsub-block is determined as a transform target, a horizontal directionaltransform type and a vertical directional transform type may be set asDST7.

As in the above-mentioned example, whether a horizontal directionaltransform type and a vertical directional transform type are set thesame may be determined according to a position of a sub-block which is atarget of a transform in a coding block. In addition, a horizontaldirectional transform type and a vertical directional transform type maybe determined according to a position of a sub-block which is a targetof a transform in a coding block.

For sub-blocks, encoding of information representing whether there is anon-zero coefficient, e.g., CBF, may be omitted. When encoding of CBF isomitted, whether a non-zero residual coefficient is included in eachsub-block may be determined based on a position of a block thattransform is performed. In an example, when a sub-block at a right orbottom position in a coding block to which binary tree partitioning isapplied is determined as a transform target, a CBF value for a sub-blockat a left or top position may be inferred to 0 and a CBF value for asub-block at a right or bottom position may be inferred to 1.Alternatively, when a sub-block at a left or bottom position in a codingblock to which binary tree partitioning is applied is determined as atransform target, a CBF value of a sub-block at a left or top positionmay be inferred to 1 and a CBF value of a sub-block at a right or bottomposition may be inferred to 0.

The second transform may be performed for a block that the firsttransform is performed. The second transform may be performed for atop-left sub-region in a transform block to which the first transformhas been applied.

If a residual coefficient on which the first transform and the secondtransform has been performed is encoded, a decoding device may performthe second inverse transform which is inverse process of the secondtransform for a transform block, and perform the first inverse transformwhich is inverse process of the first transform for a transform blockthat the second inverse transform has been performed.

Whether the second transform is applied to a current block may bedetermined based on at least one of a size, the number of residualcoefficients, an encoding mode or an intra-prediction mode of a currentblock, or whether a sub-partition intra encoding method is applied tothe current block or not.

In an example, when at least one of a width or a height of a currentblock is smaller than a threshold value, the second transform may not beperformed. In this case, a threshold value may be a natural number suchas 4, 8, or 16.

Alternatively, when the number of residual coefficients included in acurrent block is equal to or less than a threshold value, the secondtransform may not be performed for a current block. In an example, whena current block includes only a single residual coefficient of a DCcomponent, the second transform may not be performed.

Alternatively, when a current block is encoded by inter-prediction, itmay be set not to apply the second transform.

Alternatively, although a current block is encoded by intra-prediction,it may be set not to apply the second transform when matrix-basedintra-prediction is performed.

Information representing whether the second transform is applied may besignaled in a bitstream. In an example, it may be one of a flagrepresenting whether the second transform is applied or indexinformation specifying a non-separable transform matrix used in thesecond transform. When a value of a flag or an index signaled in abitstream is 0, it represents that the second transform is not applied.When a value of a flag or an index is equal to or greater than 1, itrepresents that the second transform is applied.

Alternatively, whether a syntax representing whether the secondtransform is applied is encoded may be determined by using a parameterrelated to a current block for determining whether the second transformis applied, which is enumerated above.

In an example, when at least one of a size, the number of residualcoefficients, an encoding mode or an intra-prediction mode of a currentblock, or whether a sub-partition intra encoding method is applied ornot does not satisfy a preset condition, encoding of a syntaxrepresenting whether the second transform is applied or not may beomitted. When encoding of the syntax is omitted, the second transformmay not be applied.

Based on the above-mentioned description, a method of performing thesecond transform in an encoding device and a decoding device will bedescribed in detail.

The second transform may be performed for a top-left sub-region in acurrent block. A sub-region may have a predefined size or a predefinedshape. A sub-region that the second transform is performed may have asquare block shape such as 4×4 or 8×8 or a non-square block shape suchas 4×8 or 8×4.

Alternatively, when a current block is uniformly partitioned into Nregions, at least one of N regions may be set as a sub-region. In thiscase, N may be a natural number such as 2, 4, 8, or 16. A variable N maybe predefined in an encoding device and a decoding device.Alternatively, a variable N may be determined based on a size and/or ashape of a current block.

Alternatively, a sub-region may be determined based on the number oftransform coefficients. In an example, the predetermined number oftransform coefficients may be determined as a sub-region according to apredetermined scanning order.

Alternatively, information for specifying a size and/or a shape of asub-region may be encoded and transmitted in a bitstream. Theinformation may include at least one of information representing a sizeof a sub-region or information representing the number of 4×4 blocksincluded in a sub-region.

Alternatively, a entirety of a current block may be set as a sub-region.In an example, when a size of a current block is the same as the minimumsize (e.g., 4×4) of a sub-region, a entirety of a current block may beset as a target for the second transform.

The second transform may be applied in a non-separable form.Accordingly, the second transform may be also referred to asNon-Separable Secondary Transform (NSST).

A transform coefficient in a sub-region that the second transform isapplied may be arranged in a single column. In an example, when thesecond transform is performed for an N×N sized sub-region, transformcoefficients included in a sub-region may be converted into an N²×1sized input matrix. When a 4×4 sized block is set as a sub-region,transform coefficients included in a sub-region may be converted into a16×1 sized input matrix. When an 8×8 sized block is set as a sub-region,transform coefficients included in a sub-region may be converted into a64×1 sized input matrix.

A non-separable transform matrix may be applied to an input matrixgenerated by arranging transform coefficients included in a sub-regionin a line. A size of a non-separable transform matrix may be differentlydetermined according to a size of an input matrix.

In an example, when a size of an input matrix is N²×1, the secondtransform may be performed based on an N²×N² sized non-separabletransform matrix. For example, when a size of an input matrix is 16×1, a16×16 sized non-separable transform matrix may be used and when a sizeof an input matrix is 64×1, a 64×64 sized non-separable transform matrixmay be used.

A plurality of non-separable transform matrixes may be stored in anencoding device and a decoding device. Information for specifying anyone of a plurality of non-separable transform matrixes may be signaledin a bitstream.

Alternatively, a non-separable transform matrix may be specified basedon at least one of a size, a shape, a quantization parameter, anintra-prediction mode or a transform type of a current block used in thefirst transform.

Alternatively, non-separable transform matrix candidates which may beused by a current block may be specified based on at least one of asize, a shape, a quantization parameter, an intra-prediction mode or atransform type of a current block used in the first transform. Whenthere is a plurality of non-separable transform matrix candidates whichmay be used by a current block, information indicating one of theplurality of non-separable transform matrix candidates may be encodedand signaled.

A transform matrix may be obtained by multiplying a non-separabletransform matrix and an input matrix. In an example, Equation 14 showsan example in which a transform matrix A′ is obtained.A′=T*A  [Equation 14]

In the Equation 14, T represents a non-separable transform matrix and Arepresents an input matrix. When a size of a matrix T is N²×N² and asize of a matrix A is N²×1, a N²×1 sized transform matrix A may beobtained. In an example, when a 16×1 sized input matrix and a 16×16sized non-separable transform matrix are used, a 16×1 sized transformmatrix A′ may be obtained. Alternatively, when a 64×1 sized input matrixand a 64×64 sized non-separable transform matrix are used, a 64×1 sizedtransform matrix A′ may be obtained.

When a transform matrix A′ is obtained, components in a transform matrixA′ may be set as transform coefficients of an N×N sized block in acurrent block. Transform coefficients in a residual region excluding theN×N sized block may be set as a default value. In an example, transformcoefficients in a region where the second transform is not performed maybe set to 0.

The second transform may be performed by using a non-separable transformmatrix that the number of rows is smaller than that of columns. In anexample, a (k×N²) sized non-separable transform matrix may be applied toa (N²×1) sized input matrix A. In this case, k may have a value smallerthan N². In an example, k may be N²/2, N²/4 or 3N²/4, etc. k may bereferred to as a reduce factor.

As a result, a (k×1) sized transform matrix smaller than an input matrixmay be obtained. Like this, the second transform that a transform matrixwith a size smaller than an input matrix is output may be referred to asReduced Secondary Transform.

Equation 15 represents an example in which the reduced second transformis applied.A _(R) =R*A  [Equation 15]

In Equation 15, R represents a k×N² sized non-separable transformmatrix. A non-separable transform matrix that k, the number of rows, issmaller than N², the number of columns, may be referred to as a reducednon-separable transform matrix. A_(R) represents a k×1 sized transformmatrix. A transform matrix A_(R) with a size smaller than an inputmatrix A may be referred to as a reduced transform matrix.

When a reduced transform matrix A_(R) is obtained, components in areduced transform matrix A_(R) may be set as transform coefficients ofat least one or more M×M sized blocks in a current block. In this case,M may be a natural number smaller than N. The number of M×M sized blocksmay be determined according to a reduce factor k. A transformcoefficient of a residual region excluding at least one M×M sized blocksmay be set as a default value. In an example, transform coefficients inthe residual region may be set to 0.

FIG. 49 is a diagram showing an encoding aspect of a transformcoefficient when a reduce factor is 16.

Transform coefficients included in an 8×8 sized sub-region may betransformed into a 64×1 sized input matrix and a 16×1 sized transformmatrix may be obtained by using a 16×64 sized non-separable transformmatrix.

A 16×1 sized transform matrix may be set as a transform coefficient of a4×4 block and transform coefficients in other regions may be set to 0.

Not shown, but when a reduce factor k is 32, a 32×1 sized transformmatrix may be set as a transform coefficient of an 8×4 block or a 4×8block and transform coefficients in other regions may be set to 0.

When a reduce factor k is 48, a 48×1 sized transform matrix may be setas a transform coefficient of three 4×4 blocks and transformcoefficients in other regions may be set to 0. Concretely, a transformmatrix may be set as a transform coefficient of a 4×4 block at atop-left position of a current block, a 4×4 block adjacent to the rightof the top-left block and a 4×4 block adjacent to the bottom of thetop-left block.

When residual transform coefficients excluding transform coefficientsgenerated by the second transform are set to 0, a decoding device maydetermine whether the second transform is performed based on a positionof the last non-zero residual coefficient. In an example, when the lastresidual coefficient is positioned outside a block that transformcoefficients generated by the second transform are stored, it may bedetermined not to perform the second transform. In other words, adecoding device may perform inverse transform for the second transformonly when the last residual coefficient is positioned in a block thattransform coefficients generated by the second transform are stored.

Whether the reduced second transform is performed or not may bedetermined based on at least one of a size or a shape of a currentblock. In an example, when at least one of a width or a height of acurrent block is greater than a threshold value, the reduced secondtransform may be applied and otherwise, the general second transform maybe applied. In this case, a threshold value may be a natural number suchas 4, 8 or 16.

Alternatively, whether the reduced second transform is performed or notmay be determined according to a size of a sub-region. In an example,when the second transform is performed for a 4×4 sized sub-region, thegeneral second transform may be applied. In an example, for a 4×4 sizedsub-region, the second transform may be performed by using a 16×16 sizednon-separable transform matrix.

On the other hand, when the second transform is performed for an 8×8sized sub-region, the reduced second transform may be applied. In anexample, for an 8×8 sized sub-region, the second transform may beperformed by using a 48×64, 32×64 or 16×64 sized non-separable transformmatrix.

When inverse transform for the reduced second transform is performed, asize of an output matrix has a value greater than that of an inputmatrix. In an example, when a reduce factor k is 16, a 64×1 sized outputmatrix may be obtained by performing inverse transform for a 16×1 sizedinput matrix.

A decoding device may decode a residual coefficient in a bitstream andderive a transform coefficient by performing dequantization on theresidual coefficient. When a transform coefficient is generated throughthe first transform and the second transform, a residual sample may bederived by performing the second inverse transform and the first inversetransform for a transform coefficient.

When it is determined to perform the second transform on a currentblock, a sub-region which is a target of the second inverse transformmay be determined. As described above, a sub-region may include a squareblock, a non-square block or a plurality of blocks.

An input matrix may be generated by arranging transform coefficientsincluded in a sub-region in a line. In this case, when the reducedsecond transform is applied to a current block, an input matrix may begenerated based on as many transform coefficients as a reduce factor k.In an example, when a reduce factor k is 16, an input matrix may begenerated based on transform coefficients included in a 4×4 sizedtop-left block. When a reduce factor k is 32, an input matrix may begenerated based on transform coefficients included in a top-left blockand a 4×4 sized neighboring block adjacent to the right or the bottom ofthe top-left block. When a reduce factor k is 48, an input matrix may begenerated based on transform coefficients of a top-left block, a 4×4sized neighboring block adjacent to the right of the top-left block anda 4×4 sized neighboring block adjacent to the bottom of the top-leftblock.

A reduce factor k may be predefined in an encoding device and a decodingdevice. Alternatively, information for determining a reduce factor k maybe signaled in a bitstream. Alternatively, a reduce factor k may bedetermined based on a size or a shape of a current block.

A transform matrix may be obtained by multiplying an input matrix and anon-separable inverse transform matrix. A non-separable inversetransform matrix may be a symmetric matrix of a non-separable transformmatrix shown in Equation 14 to Equation 15. Equation 16 and Equation 17show an example in which a transform matrix is obtained by using anon-separable inverse transform matrix.A′=T ^(T) *A  [Equation 16]

When the general second transform is applied to a current block, atransform matrix may be derived by multiplying an input matrix A by anon-separable inverse transform matrix T^(T). In an example, a 16×1sized transform matrix may be derived by multiplying a 16×16 sizedinverse transform matrix T^(T) and a 16×1 sized input matrix A.

When a transform matrix A′ is obtained, components in a transform matrixA′ may be set as transform coefficients of an N×N sized block in acurrent block. In an example, a 16×1 sized transform matrix may be setas a transform coefficient of a 4×4 block.A′=R ^(T) *A  [Equation 17]

When the reduced second transform is applied to a current block, atransform matrix A′ may be derived by multiplying an input matrix A by areduced non-separable inverse transform matrix R^(T). In an example, a64×1 sized transform matrix may be derived by multiplying a 64×16 sizedreduced non-separable inverse transform matrix R^(T) and a 16×1 sizedinput matrix A.

Alternatively, a 64×1 sized transform matrix may be derived bymultiplying a 64×32 sized reduced non-separable inverse transform matrixR^(T) and a 32×1 sized input matrix A.

Alternatively, a 48×1 sized transform matrix may be derived bymultiplying a 64×48 sized reduced non-separable inverse transform matrixR^(T) and a 48×1 sized input matrix A.

When a transform matrix A′ is obtained, components in a transform matrixA′ may be set as transform coefficients of an N×N sized block in acurrent block. In an example, a 64×1 sized transform matrix may be setas a transform coefficient of a 8×8 block.

When a sub-partition intra encoding method is applied to a currentblock, it may be set not to apply the second transform.

Alternatively, when a sub-partition intra encoding is applied to acurrent block and at least one of a width or a height is greater than athreshold value, it may be set to apply the second transform. Athreshold value may be a natural number such as 2, 4, 8, or 16. In anexample, the second transform may be applied to a current block onlywhen a current block is partitioned into 4×N or N×4 shaped partitions.In this case, N may be a natural number equal to or greater than 4.

Alternatively, when a sub-partition intra encoding is applied to acurrent block, the second transform may be applied to a current blockonly when a predefined transform type is used for the first transform.In this case, a predefined transform type may include at least one ofDCT2, DST7 or DCT8.

The second transform may be applied only to part of a plurality ofsub-partitions included in a current block. In an example, the secondtransform may be applied only to a sub-partition at the uppermostposition of a current block or a sub-partition at the leftmost positionof a current block, and may not be applied to remaining sub-partitions.

Alternatively, it is also possible to determine whether to apply thesecond transform at a coding block level, but at least one of aplurality of sub-partitions can be set as a sub-region for the secondtransform. In an example, a sub-partition at the uppermost position of acurrent block or a sub-partition at the leftmost position of a currentblock may be included in a sub-region.

Alternatively, it is also possible to set a sub-region to include atop-left square block in a coding block, but do not across a pluralityof sub-partitions.

Alternatively, according to a size of a coding block, a top-left 4×4sized block or an 8×8 sized block in a coding block may be set as asub-region.

When a sub-partition included in a current block is set as a sub-region,an input matrix may be generated by arranging transform coefficientsincluded in the sub-region in a line. In an example, when a 4×8 or 8×4shaped sub-partition is set as a sub-region, transform coefficientsincluded in the sub-region may be converted into a 32×1 shaped inputmatrix.

A transform matrix may be derived by multiplying an input matrix by anon-separable transform matrix. In an example, a 32×1 sized transformmatrix may be obtained by multiplying a 32×32 sized non-separabletransform matrix and a 32×1 sized input matrix.

When a transform matrix is obtained, components in a transform matrixmay be set as transform coefficients of a sub-partition in a sub-region.Transform coefficients in remaining sub-partitions excepting thesub-region may be set to 0.

Whether the second transform is allowed may be determined based onwhether a sub-transform block encoding method is applied to a codingblock. In an example, when a sub-transform block encoding method isapplied to a coding block, it may be set not to apply the secondtransform.

Alternatively, when a sub-transform block encoding method is applied toa coding block, the second transform can be used only in at least oneavailable sub-block among a plurality of sub-blocks. In this case, anavailable sub-block may represents a block that the first transform isperformed among a plurality of sub-blocks.

FIGS. 50 and 51 are diagrams showing an example in which the secondtransform is performed for an available sub-block. FIG. 50 shows anexample of a case in which binary tree partitioning is applied and FIG.51 shows an example of a case in which quad tree partitioning isapplied.

When binary tree partitioning is applied to a coding block, the secondtransform may be performed for a sub-block that the first transform isperformed among two sub-blocks. In an example, when a coding block ispartitioned in a vertical direction and the first transform is performedonly for a left sub-block in a coding block, the second transform may beperformed for an N×N sized top-left region in the left sub-block.Transform coefficients in a right-sub-region on which the firsttransform is not performed and a remaining region excluding the N×Nsized region in the left sub-block may be set to 0.

On the other hand, when the first transform is performed only for aright sub-block in a coding block, the second transform may be performedfor an N×N sized top-left region in the right sub-block. Transformcoefficients in a left-sub-block on which the first transform is notperformed and in a remaining region excluding the N×N sized region thatthe second transform is performed in the right sub-block may be set to0.

When a coding block is partitioned in a horizontal direction and thefirst transform is performed only for a top sub-block in a coding block,the second transform may be performed for an N×N sized top-left regionin the top sub-block. Transform coefficients in a bottom-sub-block onwhich the first transform is not performed on and a remaining regionexcluding the N×N sized region that the second transform is performed inthe top sub-block may be set to 0.

When a coding block is partitioned in a horizontal direction and thefirst transform is performed only for a bottom sub-block in a codingblock, the second transform may be performed for an N×N sizedbottom-left region in the bottom sub-block. Transform coefficients in atop-sub-block on which the first transform is not performed and in aremaining region excluding the N×N sized region that the secondtransform is performed in the bottom sub-block may be set to 0.

When quad tree partitioning is applied to a coding block, the secondtransform may be performed only for a sub-block that the first transformis performed among four sub-blocks. In an example, the second transformmay be performed for an N×N sized top-left region of the sub-block thatthe first transform is performed.

A size of a sub-region in a sub-block may be determined according to asize or a shape of a sub-block. In an example, when at least one of aheight or a width of a sub-block is smaller than a threshold value, thesecond transform may be performed for a 4×4 region. On the other hand,when at least one of a height or a height of a sub-block is equal to orgreater than a threshold value, the second transform may be performedfor an 8×8 region.

Whether the second transform is applied to a sub-block may be determinedbased on at least one of a size, a shape, a position or a partitionindex of a sub-block. In an example, the second transform may be appliedonly for a sub-block including a top-left sample of a coding block.Alternatively, only when at least one of a height or a width of asub-block is greater than a threshold value, the second transform may beapplied.

Alternatively, information representing whether the second transform isapplied to a sub-block may be signaled in a bitstream.

When a sub-transform block encoding method is applied, it may be set notto allow the reduced second transform. Alternatively, although asub-transform block encoding method is applied, whether the reducedsecond transform is performed or not may be determined based on at leastone of a size or a shape of a sub-block.

A reconstructed sample of a sub-block that transform is performed may bederived by a sum of a prediction sample and a residual sample. On theother hand, a prediction sample may be set as a reconstructed sample ina sub-block that transform is omitted. Quantization is to reduce energyof a block, and a quantization process includes a process dividing atransform coefficient by a specific constant value. The constant valuemay be derived by a quantization parameter and a quantization parametermay be defined as a value from 1 to 63.

An encoding device may encode a coefficient generated by performingtransform and/or quantization (hereinafter, referred to as a residualcoefficient). In this case, a residual coefficient may be encoded percolor component. In an example, a residual coefficient for a lumacomponent, a residual coefficient for the first chroma component (e.g.,a Cb component) and a residual coefficient for the second chromacomponent (e.g., a Cr component) may be independently encoded. Adecoding device may decode a residual coefficient by decodinginformation on a residual coefficient in a bitstream and obtain aresidual sample by performing dequantization and/or inverse transformfor the residual coefficient. A reconstructed block for a current blockmay be obtained by adding a residual block including residual samplesand a prediction block.

In this case, a case in which signal characteristics between chromacomponents are similar may occur. Concretely, a case in which a samplevalue of a Cb component and a sample value of a Cr component has asimilar value each other, or a case in which a value of a predictionsample of a Cb component and or a value of a prediction sample of a Crcomponent has mutual similarity may occur.

In this case, a value of a residual sample of a Cr component and aresidual sample of a Cb component may have mutual similarity. In anexample, when a value of a residual sample of a Cr component and a valueof a residual sample of a Cb component are similar, a case in which avalue of a residual sample of a Cr component and a value of a residualsample of a Cb component have a similar absolute value, but has anopposite sign, or a case in which an absolute value of a residual sampleof a Cr component is N times that of a residual sample of a Cbcomponent, etc. may occur.

As in the above-mentioned cases, when a residual signal of a Cbcomponent and a residual signal of a Cr component have mutualsimilarity, encoding of a residual signal of any one of a Cb componentor a Cr component may be omitted and the residual signal for a chromacomponent that encoding is omitted may be derived from a encodedresidual signal of the other chroma component. Alternatively, a modifiedresidual signal representing a Cb component and a Cr component may beencoded instead of a residual signal for a Cb component and a Crcomponent. The modified residual signal may be referred to as a jointresidual signal.

In this case, a residual signal may represent at least one of a residualsample or a residual coefficient generated by applying transform and/orquantization to a residual sample.

A method of deriving a residual signal that encoding is omitted from amodified residual signal after omitting encoding of the residual signalfor at least one of the first chroma component and the second chromacomponent, may be referred to as Joint Chrominance ResidualTransformation Method. In this case, the first chroma component mayrepresent one of a Cb component or a Cr component, or may represent oneof a U or a V component. The second chroma component may represent theother.

For convenience of description, a residual signal of the first chromacomponent is referred to as the first residual signal and a residualsignal of the second chroma component is referred to as the secondresidual signal.

Hereinafter, an operation of an encoding device and a decoding deviceaccording to a joint chrominance residual transformation method will bedescribed in detail.

FIGS. 52 and 53 are diagrams showing a flow chart of a joint chrominanceresidual transformation method according to an embodiment of the presentdisclosure.

FIG. 52 represents an operation of an encoding device for application ofa joint chrominance residual transformation method and FIG. 53represents an operation of a decoding device for application of a jointchrominance residual transformation method. An embodiment shown in FIG.53 may also be used in an encoding device to generate a reconstructedimage.

A modified residual signal for the first residual signal and the secondresidual signal may be derived to determine whether to apply a jointchrominance residual transformation method S5201. When an image isreconstructed, a modified residual signal may be set as the firstresidual signal or the second residual signal.

An encoding device may omit encoding of the first residual signal andthe second residual signal and perform encoding for a modified residualsignal.

A modified residual signal may be derived based on at least one of thefirst residual signal or the second residual signal. In an example, thefirst residual signal or the second residual signal may be set as amodified residual signal.

Alternatively, a modified residual signal may be derived by averagingthe first residual signal and the second residual signal. The followingEquation 18 shows an example in which an average of the first residualsignal and the second residual signal is derived by a modified residualsignal.ResCb′=(ResCb+ResCr+1)>>1  [Equation 18]

Alternatively, a modified residual signal may be derived based on adifference of the first residual signal and the second residual signal.The following Equation 19 shows an example in which a modified residualsignal is derived based on a difference between the first residualsignal and the second residual signal.ResCb′=(ResCb−ResCr)  [Equation 19]

In Equation 18 and Equation 19, ResCb′ represents a modified residualsignal. ResCb represents a residual signal for a Cb component. ResCb maybe derived by subtracting a prediction signal of a Cb component from anoriginal signal of a Cb component. ResCr represents a residual signalfor a Cr component. ResCr may be derived by subtracting a predictionsignal of a Cr component from an original signal of a Cr component.

Alternatively, a modified residual signal may be derived based on a sumof the first residual signal and the second residual signal.

In an example, a sum of the first residual signal and the secondresidual signal may be derived as a modified residual signal or a valuereversing a sign of the sum of the first residual signal and the secondresidual signal may be derived as a modified residual signal.

Alternatively, a modified residual signal may be derived by scaling asum of the first residual signal and the second residual signal orscaling a difference of the first residual signal and the secondresidual signal.

Equation 20 to Equation 22 show various examples in which a modifiedresidual signal is derived.ResCb′=(ResCb−ResCr)>>1  [Equation 20]ResCb′=(ResCb−ResCr+2)>>2  [Equation 21]ResCb′=(ResCb+ResCr+2)>>2  [Equation 22]

An encoding device may measure a cost for various methods of generatinga modified residual signal (RD-cost) and use the lowest-cost generationmethod to generate a modified residual signal S5202.

An encoding device may determine whether a joint chrominance residualtransformation method is applied to a current block S5203. An encodingdevice may determine whether to apply a joint chrominance transformationmethod or not based on a cost, RD-cost, calculated under when a jointchrominance transformation method is applied and a cost, RD-cost,calculated under when a joint chrominance transformation method is notapplied.

An encoding device may encode a flag representing whether a jointchrominance residual transformation method is applied S5204. In anexample, a syntax, joint_cbcr_flag, may be signaled in a bitstream. Asyntax, joint_cbcr_flag, may be signaled in a block level, a slice levelor a picture level.

When it is determined to apply a joint chrominance residualtransformation method, a residual signal reconstruction mode may bedetermined based on a determined modified residual signal generationmethod. An encoding device may encode and signal information specifyinga determined modified residual signal generation method or a residualsignal reconstruction mode corresponding to it.

The information may be an index or a flag representing one of aplurality of modes. In an example, a syntax, joint_cbcr_weight_idx,representing one of a plurality of modes may be signaled in a bitstream.Table 12 represents a syntax, joint_cbcr_weight_idx, according to amodified residual signal generation method.

TABLE 12 Index of residual signal reconstruction mode Modified residualsignal (joint_cbcr_weight_idx) ResCb′ = (ResCb − ResCr + 1) >> 1 0ResCb′ = (ResCb − ResCr) 1 ResCb′ = (ResCb − ResCr + 2) >> 2 2 ResCb′ =(ResCb + ResCr + 1) >> 1 3

Alternatively, a residual signal reconstruction mode may be specified byusing CBF (coded_block_flag) representing whether there is a non-zerotransform coefficient for the first chroma component and CBFrepresenting whether there is a non-zero transform coefficient for thesecond chroma component.

An encoding device may determine a value of cbf_cr for a Cb componentand cr_cbf for a Cr component according to a determined residual signalreconstruction mode.

A decoding device may decode modified residual signal information in abitstream and derive a modified residual signal. In this case, amodified residual signal may be a residual coefficient or a residualblock generated by performing dequantization and/or inverse transformfor the residual coefficient. A decoding device may derive the firstresidual signal and the second residual signal from a modified residualsignal based on whether a joint chrominance residual transformationmethod is applied.

Concretely, a decoding device may determine whether a joint chrominanceresidual transformation method is applied to a current block S5301. Adecoding device may determine whether a joint chrominance transformationmethod is applied or not based on information parsed from a bitstream.In an example, when a value of a syntax, joint_cbcr_flag, is 1, itrepresents that a joint chrominance residual transformation method isapplied to a current block. When a value of a syntax, joint_cbcr_flag,is 0, it represents that a joint chrominance residual transformationmethod is not applied to a current block.

When it is determined to apply a joint chrominance residualtransformation method, information for specifying a residual signalreconstruction mode may be parsed from a bitstream and a residual signalreconstruction mode may be specified based on the parsed informationS5302.

The information may be an index or a flag for specifying one of aplurality of residual signal reconstruction modes. In an example, aresidual signal reconstruction mode may be determined based on a syntax,joint_cbcr_weight_idx, signaled in a bitstream.

Alternatively, a residual signal reconstruction mode may be determinedbased on CBF for the first chroma component and/or CBF for the secondchroma component.

When a residual signal reconstruction mode is determined, a residualsignal of the first chroma component and a residual signal of the secondchroma component may be derived according to a determined residualsignal reconstruction mode S5303. According to a residual signalreconstruction mode, a method of deriving a residual signal may bedifferently determined.

In an example, when a residual signal reconstruction mode whose an indexis 0 is selected, a residual signal of the first chroma component may beset the same as a modified residual signal. An absolute value of aresidual signal of the second chroma component may be set the same asthat of a modified residual signal and a sign may be set the same as ordifferently from a modified residual signal.

When a residual signal reconstruction mode whose an index is 2 isselected, a residual signal of the first chroma component may be set asa modified residual signal. An absolute value of a residual signal ofthe second chroma component may be derived by scaling a modifiedresidual signal and a sign may be set the same as or differently from amodified residual signal.

When a residual signal reconstruction mode whose an index is 3 isselected, a residual signal of the second chroma component may be set asa modified residual signal. An absolute value of a residual signal ofthe first chroma component may be derived by scaling a modified residualsignal and a sign may be set the same as a modified residual signal.

Whether a modified residual signal is the same as a residual signal ofthe first chroma component or whether a modified residual signal is thesame as a residual signal of the second chroma component may bedetermined according to CBF of the first chroma component and/or CBF ofthe second chroma component.

In an example, when CBF, cb_cbf, for a Cb component is 1, it representsthat a residual coefficient is encoded for a Cb component. When asyntax, cb_cbf, is 1, a modified residual signal may be derived bydecoding a residual coefficient for a Cb component or performingdequantization and/or inverse transform for the decoded residualcoefficient for a Cb component. When a syntax, cb_cbf, is 1, a residualsignal of a Cb component may be set the same as a modified residualsignal.

When a syntax, cb_cbf, is 0, it represents that a residual coefficientis not encoded for a Cb component. When a syntax, cb_cbf, is 0, or whencb_cbf is 0 and cr_cbf is 1, a modified residual signal may be derivedby decoding a residual coefficient for a Cr component or performingdequantization and/or inverse transform for a decoded residualcoefficient for a Cr component. When a syntax, cb_cbf, is 0, a residualsignal of a Cr component may be set the same as a modified residualsignal.

Alternatively, whether a modified residual signal is the same as aresidual signal of a Cr component may be determined based on CBF of a Crcomponent, cr_cbf.

Information representing whether at least one of a residual signal ofthe first chroma component or a residual signal of the second chromacomponent has a sign different from a modified residual signal may besignaled in a bitstream. In an example, a syntax, joint_cbcr_sign_flag,may be signaled in a bitstream. When a syntax, joint_cbcr_sign_flag, is0, it represents that a sign of the first chroma component and thesecond chroma component is the same as a modified residual signal. Onthe other hand, when a syntax, joint_cbcr_sign_flag, is 1, it representsthat a sign of one of the first chroma component or the second chromacomponent is different from a modified residual signal.

When the first residual signal and the second residual signal are setthe same as a modified residual signal, a reconstruction image of thefirst chroma component may be derived by adding the first predictionsignal to a modified residual signal and a reconstruction image of thesecond chroma component may be derived by adding the second predictionsignal to a modified residual signal. In an example, Equation 23 showsan example in which the first residual signal and the second residualsignal are set the same as a modified residual signal.RecCb=DResCb+PredCbRecCr=DResCb+PredCr  [Equation 23]

On the other hand, when the first residual signal is derived the same asa modified residual signal and the second residual signal has the sameabsolute value as a modified residual signal, but has a different sign,a reconstruction image of the first chroma component may be derived byadding the first prediction signal to a modified residual signal and areconstruction image of the second chroma component may be derived bysubtracting a modified residual signal from the second predictionsignal. In an example, Equation 24 shows an example in which signs ofthe first residual signal and the second residual signal are setdifferently.RecCb=DResCb′+PredCbRecCr=−DResCb′+PredCr  [Equation 24]

In Equation 23 and Equation 24, DResCb′ represents a decoded modifiedresidual signal. DResCb′ may be obtained by performing dequantizationand/or inverse transform for a residual coefficient. RecCb represents areconstruction signal of a Cb component and PredCb represents aprediction signal of a Cb component. RecCr represents a reconstructionsignal of a Cr component and PredCr represents a prediction signal of aCr component.

Encoding of a syntax specifying a value of a residual signalreconstruction mode may be omitted and the residual signalreconstruction mode may be determined by using neighboring samplesadjacent to a current block. In an example, a residual signalreconstruction mode may be derived by using neighboring Cb samplesadjacent to a Cb block and neighboring Cr samples adjacent to a Crblock.

Alternatively, a residual signal reconstruction mode of a current blockmay be derived by a residual signal reconstruction mode of a neighboringblock adjacent to a current block. In an example, a residual signalreconstruction mode of a neighboring block adjacent to the top or theleft of a current block may be set as a residual signal reconstructionmode of a current block.

When a joint chrominance residual transformation method is applied to acurrent block, it may be set not to allow transform skip to decode atransform residual signal. In an example, when a syntax,joint_cbcr_flag, is 1, encoding of a flag, transform_skip_flag,representing whether transform skip is applied may be omitted and avalue of that may be inferred to be 0.

Alternatively, although a joint chrominance residual transformationmethod is applied, transform skip may be allowed. In this case,according to a residual signal reconstruction mode, transform skip maybe allowed only for one of the first chroma component or the secondchroma component.

When transform skip is applied, a value of a modified residual signalgeneration mode or a residual signal reconstruction mode may be set as adefault.

Whether a joint chrominance residual transformation method is allowedmay be determined according to a color format of a current picture. Inan example, only when a color format of a current picture is 4:2:0 or4:2:2, a joint chrominance residual transformation method may be allowedand when a color format of a current picture is 4:4:4, a jointchrominance residual transformation method may not be allowed.

Alternatively, although a color format of a current picture is 4:4:4, ajoint chrominance residual transformation method may be allowed.

Alternatively, whether a joint chrominance residual transformationmethod is allowed may be determined based on at least one of a size, ashape or an encoding mode of a current block. In an example, a jointchrominance residual transformation method may be allowed when a size ofa current block is equal to or greater than a threshold value or equalto or less than a threshold value. Alternatively, a joint chrominanceresidual transformation method may be allowed only when a current blockis encoded by inter-prediction.

When a joint chrominance transformation method is not allowed, encodingof a syntax, joint_cbcr_flag, may be omitted and a value of that may beinferred to be 0.

It is also possible to jointly encode/decode a residual signal between aluma component and a chroma component. In an example, a joint residualsignal encoding/decoding method may be applied to a luma component and aCb component, or a joint residual signal encoding/decoding method may beapplied to a luma component and a Cr component.

Only when a color format of a current picture is 4:4:4, a joint residualsignal encoding/decoding method between a luma component and a chromacomponent may be allowed.

When the reconstructed block of the current block is obtained, loss ofinformation as occurring in the process of the quantization and encodingmay be reduced via the in-loop filtering. The in-loop filter may includeat least one of a deblocking filter, a sample adaptive offset filter(SAO), or an adaptive loop filter (ALF). Hereinafter, a reconstructedblock before an in-loop filter is applied is referred to as the firstreconstructed block and a reconstructed block after an in-loop filter isapplied is referred to as the second reconstructed block.

The second reconstructed block may be obtained by applying at least oneof a deblocking filter, SAO or ALF to the first reconstructed block. Inthis case, SAO or ALF may be applied after a deblocking filter isapplied.

Applying the embodiments as described about the decoding process or theencoding process to the encoding process or the decoding processrespectively may be included in the scope of the present disclosure.Within the scope of the present disclosure, the embodiments in whichoperations occur in a predetermined order may be modified to embodimentsin which the operations occur in a different order from thepredetermined order.

Although the above-described embodiment is described based on a seriesof the operations or the flowchart, the embodiment does not limit atime-series order of the operations of the method thereto. In anotherexample, the operations may be performed simultaneously or in adifferent order therefrom as necessary. Further, in the above-describedembodiment, each of the components (for example, a unit, a module, etc.)constituting the block diagram may be implemented in a form of ahardware device or software. A plurality of components may be combinedwith each other into a single component which may be implemented using asingle hardware device or software. The above-described embodiment maybe implemented using program instructions that may be executed viavarious computer components. The instructions may be recorded in acomputer-readable storage medium. The computer-readable storage mediummay contain therein program instructions, data files, data structures,or the like alone or in combination with each other. Examples of thecomputer-readable storage media include magnetic media such as harddisks, floppy disks, and magnetic tapes, optical storage media such asCD-ROMs, DVDs, and magneto-optical media such as floptical disks, andhardware devices such as ROM, RAM, flash memory, and the likespecifically configured to store therein and execute the programinstructions. The hardware device may be configured to operate as one ormore software modules to perform processing according to the presentdisclosure, and vice versa.

INDUSTRIAL AVAILABILITY

The present disclosure may be applied to an electronic device thatencodes/decodes video.

What is claimed is:
 1. A method of decoding a video, the methodcomprising: deriving a residual coefficient of a current block;dequantizing the residual coefficient; and deriving a joint residualsample by performing an inverse transform for the dequantized residualcoefficient, wherein both a first residual sample for a first chromacomponent and a second residual sample for a second chroma component arederived from the joint residual sample, and wherein one of the firstresidual sample and the second residual sample has the same sign as thejoint residual sample and the other has a sign opposite to the jointresidual sample.
 2. The method of claim 1, wherein when a first jointresidual signal decoding mode is selected, an absolute value of thefirst residual sample is derived to be the same as the joint residualsample and when a second joint residual signal decoding mode isselected, the absolute value of the first residual sample is derived byscaling the joint residual sample.
 3. The method of claim 2, wherein aselection of the first joint residual signal decoding mode and thesecond joint residual signal decoding mode is based on informationparsed from a bitstream.
 4. The method of claim 2, wherein a selectionof the first joint residual signal decoding mode and the second jointresidual signal decoding mode is based on a first coded block flagrepresenting whether there is a non-zero residual coefficient of thefirst chroma component in the current block and a second coded blockflag representing whether there is a non-zero residual coefficient ofthe second chroma component in the current block.
 5. A method ofencoding a video, the method comprising: generating a joint residualsample for a first residual sample for a first chroma component and asecond residual sample for a second chroma component; transforming thejoint residual sample; deriving a residual coefficient by quantizing thetransformed joint residual sample; and encoding the residualcoefficient, wherein residual coefficients for a single transform blockare encoded instead of encoding residual coefficients both of a firsttransform block for the first chroma component and a second transformblock for the second chroma component, and wherein one of the firstresidual sample and the second residual sample has the same sign as thejoint residual sample and the other has a sign opposite to the jointresidual sample.
 6. The method of claim 5, wherein the method furthercomprises encoding information for selecting one of a first jointresidual signal encoding mode and a second joint residual signalencoding mode.
 7. The method of claim 6, wherein the informationincludes a first coded block flag representing whether there is anon-zero transform coefficient of the first chroma component in thecurrent block and a second coded block flag representing whether thereis a non-zero transform coefficient of the second chroma component inthe current block.
 8. The method of claim 5, wherein, under a firstjoint residual signal encoding mode, an absolute value of the firstresidual sample is derived to be the same as the joint residual sample,and wherein, under a second joint residual signal encoding mode, theabsolute value of the second residual sample is derived by scaling thejoint residual sample.
 9. A non-transitory computer readable mediumhaving stored thereon a compressed video data, the compressed video datacomprising: a residual coefficient of a current block, wherein adequantized residual coefficient is derived by performing dequantizationfor the current block, wherein a joint residual sample is derived byperforming an inverse transform for the dequantized residualcoefficient, wherein both a first residual sample for a first chromacomponent and a second residual sample for a second chroma component arederived from the joint residual sample, and wherein one of the firstresidual sample and the second residual sample has the same sign as thejoint residual sample and the other has a sign opposite to the jointresidual sample.